roomer 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/roomer/helpers/postgres_helper.rb +24 -1
- data/lib/roomer/schema.rb +9 -0
- data/lib/roomer/version.rb +1 -1
- metadata +5 -5
@@ -17,7 +17,21 @@ module Roomer
|
|
17
17
|
# lists the schemas available
|
18
18
|
# @return [Array] list of schemas
|
19
19
|
def schemas
|
20
|
-
ActiveRecord::Base.connection.query(
|
20
|
+
ActiveRecord::Base.connection.query(%{
|
21
|
+
SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*'
|
22
|
+
}).flatten.map(&:to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
# lists all stored procedures for given schema
|
26
|
+
# @return [Array] list of stored procedures
|
27
|
+
def stored_procedures(schema_name)
|
28
|
+
ActiveRecord::Base.connection.select_values(%{
|
29
|
+
SELECT proname
|
30
|
+
FROM pg_catalog.pg_namespace n
|
31
|
+
JOIN pg_catalog.pg_proc p
|
32
|
+
ON pronamespace = n.oid
|
33
|
+
WHERE nspname = '#{schema_name.to_s}'
|
34
|
+
})
|
21
35
|
end
|
22
36
|
|
23
37
|
# Ensures the schema and schema_migrations exist(creates them otherwise)
|
@@ -40,6 +54,15 @@ module Roomer
|
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
57
|
+
# Creates sequence for given table name
|
58
|
+
# @param [table_name] table for which sequence will be created
|
59
|
+
# @param [pk] primary key for table. Defaults to id
|
60
|
+
def create_sequence(table_name, pk="id")
|
61
|
+
ActiveRecord::Base.connection.execute(%{
|
62
|
+
CREATE SEQUENCE #{table_name}_#{pk}_seq OWNED BY #{table_name}.#{pk}
|
63
|
+
})
|
64
|
+
end
|
65
|
+
|
43
66
|
# Ensures the same ActiveRecord::Base#table_name_prefix for all the
|
44
67
|
# models executed in the block
|
45
68
|
# @param [#to_s] A Symbol declaring the table name prefix
|
data/lib/roomer/schema.rb
CHANGED
@@ -58,5 +58,14 @@ module Roomer
|
|
58
58
|
ActiveRecord::Base.connection.assume_migrated_upto_version(info[:version], migrations_path)
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
def self.current_schema
|
63
|
+
ActiveRecord::Base.table_name_prefix.split('.').first
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.current_tenant
|
67
|
+
return nil if current_schema == Roomer.shared_schema_name.to_s
|
68
|
+
Tenant.find_by_schema_name(current_schema)
|
69
|
+
end
|
61
70
|
end
|
62
71
|
end
|
data/lib/roomer/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roomer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 11
|
10
|
+
version: 0.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Greg Osuri
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-10-
|
19
|
+
date: 2011-10-14 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: rails
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 3.0.9
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
|
-
description: roomer 0.0.
|
37
|
+
description: roomer 0.0.11
|
38
38
|
email:
|
39
39
|
- gosuri@gmail.com
|
40
40
|
- dceballos@gmail.com
|