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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65bc627338073ea5eabfe8310752ecfa4afe8976c03c8a229fb5bff9715d00c1
4
- data.tar.gz: 0c1d62b66dfb7c4747dcadaf17acf445ad306e56d6c1ab8a81750ff04f2fbb56
3
+ metadata.gz: 1246e99417c2608f07e5661cd6402d1b5f829671c6c74d806e122edef1db74f4
4
+ data.tar.gz: e11008fa963049c5bd067c9eef70c9f89cc15dfe6569f9f1d1291a8b8f60efce
5
5
  SHA512:
6
- metadata.gz: 60688637f37e713dc0f3100ffd67ccdc12ebf03a8a9ac1fb56cdfa2e9173ad2994aab2d16da6700148d0a428ff26ee7170d9588078211a221ef8201b31aa1532
7
- data.tar.gz: a102f229ef0fc192bb28b4f8b1dcb9350203ef814cbff31908659ec5dc29829459ab33f0fb56e6e4e846376f83759b04dd092ea13d0afaab07daadaa41abce78
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 ["gmhawash@gmail.com"](mailto:"gmhawash@gmail.com").
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2026 gmhawash
3
+ Copyright (c) 2026 Eclectic Code
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Ec
4
4
  module Pg
5
- MINOR = 9
5
+ MINOR = 11
6
6
  VERSION = "0.1.#{MINOR}"
7
7
  end
8
8
  end
data/lib/ec/pg.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "pg/version"
7
7
  require_relative "pg/context"
8
8
  require_relative "pg/tenant_context"
9
9
  require_relative "pg/configuration"
10
+ require_relative "pg/migration_mixin"
10
11
 
11
12
  if ENV['RAILS_ENV'] == 'test'
12
13
  require 'debug'
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.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
- - gmhawash
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
- - gmhawash@gmail.com
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