ec-pg 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/LICENSE.txt +1 -1
- data/lib/ec/pg/migration_mixin.rb +34 -0
- data/lib/ec/pg/version.rb +1 -1
- data/lib/ec/pg.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1246e99417c2608f07e5661cd6402d1b5f829671c6c74d806e122edef1db74f4
|
|
4
|
+
data.tar.gz: e11008fa963049c5bd067c9eef70c9f89cc15dfe6569f9f1d1291a8b8f60efce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5d79bdba37b2dcbf66fb6463d2f3fe9a88b040301f0ae6fe405c439c2aa3d371c42437f8777cea2bb5cf277faba658b3fc8ac7228d9e5ae77b5dd5440c6ccfe
|
|
7
|
+
data.tar.gz: bc521e11d2a4baa2aa8f9c9d58222fd2775512a121dc910a3631464971fb8311a1d73d54a2381fbbaf1b0a39c0b142320a64a54ed87c18a723961a7253fc6131
|
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* When interpreting the words and actions of others, participants should always assume good intentions.
|
|
8
8
|
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
9
9
|
|
|
10
|
-
If you have any concerns about behaviour within this project, please contact us at ["
|
|
10
|
+
If you have any concerns about behaviour within this project, please contact us at ["gxssd624@duck.com"](mailto:"gxssd624@duck.com").
|
data/LICENSE.txt
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ec
|
|
4
|
+
module Pg
|
|
5
|
+
module MigrationMixin
|
|
6
|
+
def create_type(name, allow_blank: true)
|
|
7
|
+
values = allow_blank ? ['', 'null'] : []
|
|
8
|
+
values += I18n.t('database_types.%s' % name).absolute_deepest_keys.map(&:to_s)
|
|
9
|
+
quoted_values = values.map{|x| quote(x)}.join(',')
|
|
10
|
+
execute <<-SQL
|
|
11
|
+
CREATE TYPE #{Ec::Pg::SchemaManager.current_schema}.#{name} as ENUM (#{quoted_values});
|
|
12
|
+
SQL
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def drop_type(name)
|
|
16
|
+
execute <<-SQL
|
|
17
|
+
DROP TYPE IF EXISTS #{Ec::Pg::SchemaManager.current_schema}.#{name};
|
|
18
|
+
SQL
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add_values_to_type(name, values, instruction = '')
|
|
23
|
+
execute('commit;') # The Alter Type query cannont happen inside a SQL transaction, so quit it.
|
|
24
|
+
values.each do |value|
|
|
25
|
+
execute "ALTER TYPE #{Ec::Pg::SchemaManager.current_schema}.#{name} ADD VALUE IF NOT EXISTS #{quote(value)} #{instruction}"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if Object.const_defined?("ActiveRecord::Migration")
|
|
33
|
+
ActiveRecord::Migration.send(:include, Ec::Pg::MigrationMixin)
|
|
34
|
+
end
|
data/lib/ec/pg/version.rb
CHANGED
data/lib/ec/pg.rb
CHANGED
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ec-pg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Eclectic Code
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
@@ -137,7 +137,7 @@ dependencies:
|
|
|
137
137
|
version: '0'
|
|
138
138
|
description: Multitenant implemntations using shards, schemas and RLS
|
|
139
139
|
email:
|
|
140
|
-
-
|
|
140
|
+
- gxssd624@duck.com
|
|
141
141
|
executables: []
|
|
142
142
|
extensions: []
|
|
143
143
|
extra_rdoc_files: []
|
|
@@ -153,6 +153,7 @@ files:
|
|
|
153
153
|
- lib/ec/pg/configuration.rb
|
|
154
154
|
- lib/ec/pg/context.rb
|
|
155
155
|
- lib/ec/pg/middleware/context_switcher.rb
|
|
156
|
+
- lib/ec/pg/migration_mixin.rb
|
|
156
157
|
- lib/ec/pg/migrator.rb
|
|
157
158
|
- lib/ec/pg/mixin.rb
|
|
158
159
|
- lib/ec/pg/railtie.rb
|