dynamic_migrations 3.6.3 → 3.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b60f89c7a66fe00d71581049f4886a5baa6ca89255dbb47315637bfa6fc5d9be
4
- data.tar.gz: cde91d7188a94a3443c8331c6efa9e966a8e86fee236fb156adc577cfebbc156
3
+ metadata.gz: ffc5194d0e153bdd70a23f5e5b83a3b916d06f1f0b27ea044f9dfab6ef0faa8f
4
+ data.tar.gz: 901bf23a5e92dfd68bc45fea4945aa7ac2930b4d7c2d1217196d3b16228076b2
5
5
  SHA512:
6
- metadata.gz: 2a047c9a0d916de3bd28cd8bf41cbb91d7603eb562d68a5e5a9c099a1418d25a9756787ed735fe0badd8de712418366567b3af65cb86cf1c6b3c3898390c8415
7
- data.tar.gz: 6ff07ad81f425dc6c2804e4dc38c36ee4122ff89b449fa9c98065213ca2730f0cf3f4e3c014f465482835c54d6d3f52453a0e0b463a694517b6c0c039e0bb3e9
6
+ metadata.gz: 464de1cbaffead85f9be5bb65c0146984d78c607a95d3ea2ba33293966eb5065f1542867b8667364388e54a06d50a8062919dc512324001b23d1f2fcd4e0ad62
7
+ data.tar.gz: 5d30a1b918c09e6d5206e1dd0c0c4963f0b23c0a92b4282c306b9465ed5825f3f0e321c76c274eaa4f465a6f02e907ec1864320ef26f9793e812e9bd0abaea82
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.6.4](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.3...v3.6.4) (2023-09-13)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * using active records standard disable/enable_extension, and create/drop schema methods ([4a73e5c](https://github.com/craigulliott/dynamic_migrations/commit/4a73e5c2d6642bdd9c5f61164a044bbed9032da9))
9
+
3
10
  ## [3.6.3](https://github.com/craigulliott/dynamic_migrations/compare/v3.6.2...v3.6.3) (2023-09-13)
4
11
 
5
12
 
@@ -21,7 +21,6 @@ module DynamicMigrations
21
21
  class MissingFunctionBlockError < StandardError
22
22
  end
23
23
 
24
- include Schema
25
24
  include Validation
26
25
  include ForeignKeyConstraint
27
26
  include Table
@@ -6,8 +6,10 @@ module DynamicMigrations
6
6
  # note that removals come before additions, and that the order here optomizes
7
7
  # for dependencies (i.e. columns have to be created before indexes are added and
8
8
  # triggers are removed before functions are dropped)
9
- add_structure_template [:create_extension], "Create Extension"
10
- add_structure_template [:drop_extension], "Drop Extension"
9
+ add_structure_template [:disable_extension], "Drop Extension"
10
+ add_structure_template [:enable_extension], "Create Extension"
11
+ add_structure_template [:drop_schema], "Drop this schema"
12
+ add_structure_template [:create_schema], "Create this schema"
11
13
  end
12
14
  end
13
15
  end
@@ -2,23 +2,23 @@ module DynamicMigrations
2
2
  module Postgres
3
3
  class Generator
4
4
  module Extension
5
- def create_extension extension_name, code_comment = nil
5
+ def enable_extension extension_name, code_comment = nil
6
6
  # no table or schema name for this fragment (it is executed at the database level)
7
- add_fragment migration_method: :create_extension,
7
+ add_fragment migration_method: :enable_extension,
8
8
  object: extension_name,
9
9
  code_comment: code_comment,
10
10
  migration: <<~RUBY
11
- create_extension "#{extension_name}"
11
+ enable_extension "#{extension_name}"
12
12
  RUBY
13
13
  end
14
14
 
15
- def drop_extension extension_name, code_comment = nil
15
+ def disable_extension extension_name, code_comment = nil
16
16
  # no table or schema name for this fragment (it is executed at the database level)
17
- add_fragment migration_method: :drop_extension,
17
+ add_fragment migration_method: :disable_extension,
18
18
  object: extension_name,
19
19
  code_comment: code_comment,
20
20
  migration: <<~RUBY
21
- drop_extension "#{extension_name}"
21
+ disable_extension "#{extension_name}"
22
22
  RUBY
23
23
  end
24
24
  end
@@ -144,10 +144,10 @@ module DynamicMigrations
144
144
  raise NoFragmentsError if fragments.empty?
145
145
 
146
146
  if fragments_for_method? :create_schema
147
- :"create_#{first_fragment_using_migration_method(:create_schema).schema_name}_schema"
147
+ :"create_#{fragments.first&.object_name}_schema"
148
148
 
149
149
  elsif fragments_for_method? :drop_schema
150
- :"drop_#{first_fragment_using_migration_method(:drop_schema).schema_name}_schema"
150
+ :"drop_#{fragments.first&.object_name}_schema"
151
151
 
152
152
  elsif fragments_for_method? :create_table
153
153
  :"create_#{first_fragment_using_migration_method(:create_table).table_name}"
@@ -164,11 +164,11 @@ module DynamicMigrations
164
164
  elsif all_fragments_for_method? [:create_enum, :add_enum_values, :drop_enum, :set_enum_comment, :remove_enum_comment]
165
165
  :enums
166
166
 
167
- elsif all_fragments_for_method? [:create_extension]
168
- (@fragments.count > 1) ? :create_extensions : :"create_#{fragments.first&.object_name}_extension"
167
+ elsif all_fragments_for_method? [:enable_extension]
168
+ (@fragments.count > 1) ? :enable_extensions : :"create_#{fragments.first&.object_name}_extension"
169
169
 
170
- elsif all_fragments_for_method? [:drop_extension]
171
- (@fragments.count > 1) ? :drop_extensions : :"drop_#{fragments.first&.object_name}_extension"
170
+ elsif all_fragments_for_method? [:disable_extension]
171
+ (@fragments.count > 1) ? :disable_extensions : :"drop_#{fragments.first&.object_name}_extension"
172
172
 
173
173
  elsif @fragments.first&.table_name
174
174
  :"changes_for_#{@fragments.first&.table_name}"
@@ -3,8 +3,8 @@ module DynamicMigrations
3
3
  class Generator
4
4
  module Schema
5
5
  def create_schema schema, code_comment = nil
6
- add_fragment schema: schema,
7
- migration_method: :create_schema,
6
+ # no table or schema name for this fragment (it is executed at the database level)
7
+ add_fragment migration_method: :create_schema,
8
8
  object: schema,
9
9
  code_comment: code_comment,
10
10
  migration: <<~RUBY
@@ -13,8 +13,8 @@ module DynamicMigrations
13
13
  end
14
14
 
15
15
  def drop_schema schema, code_comment = nil
16
- add_fragment schema: schema,
17
- migration_method: :drop_schema,
16
+ # no table or schema name for this fragment (it is executed at the database level)
17
+ add_fragment migration_method: :drop_schema,
18
18
  object: schema,
19
19
  code_comment: code_comment,
20
20
  migration: <<~RUBY
@@ -8,12 +8,9 @@ module DynamicMigrations
8
8
  # triggers are removed before functions are dropped)
9
9
  add_structure_template [:remove_function_comment, :drop_function], "Remove Functions"
10
10
  add_structure_template [:remove_enum_comment, :drop_enum], "Drop Enums"
11
- add_structure_template [:drop_schema], "Drop this schema"
12
11
  add_structure_template [:create_enum, :add_enum_values, :set_enum_comment], "Enums"
13
- add_structure_template [:create_schema], "Create this schema"
14
12
  add_structure_template [:create_function], "Functions"
15
13
  add_structure_template [:update_function, :set_function_comment], "Update Functions"
16
- add_structure_template [:create_extension, :drop_extension], "Extensions"
17
14
 
18
15
  def initialize schema_name
19
16
  raise MissingRequiredSchemaName unless schema_name
@@ -72,10 +72,11 @@ module DynamicMigrations
72
72
  schema_migration = schema_migrations[:schema_migration] ||= SchemaMigration.new(schema_name)
73
73
  schema_migration.add_fragment fragment
74
74
 
75
- # migrations with no schema or table, are added to a database
76
- # migration (these re really just creating/dropping extensions)
75
+ # migrations with no schema or table, are added to a database
76
+ # migration (these are really just creating/dropping schemas and extensions)
77
77
  elsif schema_name.nil? && table_name.nil?
78
78
  database_specific_migration.add_fragment fragment
79
+
79
80
  else
80
81
  raise UnprocessableFragmentError
81
82
  end
@@ -12,13 +12,13 @@ module DynamicMigrations
12
12
  # then we have to create it
13
13
  if configuration_extension[:exists] == true && !database_extension[:exists]
14
14
  # a migration to create the extension
15
- @generator.create_extension extension_name
15
+ @generator.enable_extension extension_name
16
16
 
17
17
  # if the extension exists in the database but not in the configuration
18
18
  # then we need to delete it
19
19
  elsif database_extension[:exists] == true && !configuration_extension[:exists]
20
20
  # a migration to drop the extension
21
- @generator.drop_extension extension_name
21
+ @generator.disable_extension extension_name
22
22
  end
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicMigrations
4
- VERSION = "3.6.3"
4
+ VERSION = "3.6.4"
5
5
  end
@@ -87,7 +87,6 @@ require "dynamic_migrations/postgres/generator/schema_migration"
87
87
  require "dynamic_migrations/postgres/generator/table_migration"
88
88
  require "dynamic_migrations/postgres/generator/migration_dependency_sorter"
89
89
 
90
- require "dynamic_migrations/active_record/migrators/schema"
91
90
  require "dynamic_migrations/active_record/migrators/validation"
92
91
  require "dynamic_migrations/active_record/migrators/foreign_key_constraint"
93
92
  require "dynamic_migrations/active_record/migrators/unique_constraint"
@@ -6,7 +6,6 @@ module DynamicMigrations
6
6
  module Migrators
7
7
  self.@current_schema: nil
8
8
 
9
- include Schema
10
9
  include Validation
11
10
  include ForeignKeyConstraint
12
11
  include Column
@@ -5,8 +5,8 @@ module DynamicMigrations
5
5
  module Postgres
6
6
  class Generator
7
7
  module Extension
8
- def create_extension: (Symbol extension_name, ?String? code_comment) -> Fragment
9
- def drop_extension: (Symbol extension_name, ?String? code_comment) -> Fragment
8
+ def enable_extension: (Symbol extension_name, ?String? code_comment) -> Fragment
9
+ def disable_extension: (Symbol extension_name, ?String? code_comment) -> Fragment
10
10
 
11
11
  # these come from the generator object (which this module is included into)
12
12
  def add_fragment: (migration_method: Symbol, object: untyped, migration: String, ?schema: Server::Database::Schema?, ?table: Server::Database::Schema::Table?, ?code_comment: String?, ?dependent_table: Server::Database::Schema::Table?) -> untyped
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.3
4
+ version: 3.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott
@@ -71,7 +71,6 @@ files:
71
71
  - lib/dynamic_migrations/active_record/migrators/foreign_key_constraint.rb
72
72
  - lib/dynamic_migrations/active_record/migrators/function.rb
73
73
  - lib/dynamic_migrations/active_record/migrators/index.rb
74
- - lib/dynamic_migrations/active_record/migrators/schema.rb
75
74
  - lib/dynamic_migrations/active_record/migrators/table.rb
76
75
  - lib/dynamic_migrations/active_record/migrators/trigger.rb
77
76
  - lib/dynamic_migrations/active_record/migrators/unique_constraint.rb
@@ -163,7 +162,6 @@ files:
163
162
  - sig/dynamic_migrations/active_record/migrators/foreign_key_constraint.rbs
164
163
  - sig/dynamic_migrations/active_record/migrators/function.rbs
165
164
  - sig/dynamic_migrations/active_record/migrators/index.rbs
166
- - sig/dynamic_migrations/active_record/migrators/schema.rbs
167
165
  - sig/dynamic_migrations/active_record/migrators/table.rbs
168
166
  - sig/dynamic_migrations/active_record/migrators/trigger.rbs
169
167
  - sig/dynamic_migrations/active_record/migrators/unique_constraint.rbs
@@ -1,21 +0,0 @@
1
- module DynamicMigrations
2
- module ActiveRecord
3
- module Migrators
4
- module Schema
5
- def create_schema
6
- # schema_name was not provided to this method, it comes from the migration class
7
- execute <<~SQL
8
- CREATE SCHEMA #{schema_name};
9
- SQL
10
- end
11
-
12
- def drop_schema
13
- # schema_name was not provided to this method, it comes from the migration class
14
- execute <<~SQL
15
- DROP SCHEMA #{schema_name};
16
- SQL
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,17 +0,0 @@
1
- # TypeProf 0.21.7
2
-
3
- # Classes
4
- module DynamicMigrations
5
- module ActiveRecord
6
- module Migrators
7
- module Schema
8
- def create_schema: () -> void
9
- def drop_schema: () -> void
10
-
11
- # stubbing these out, as they are available on the module which includes this module
12
- def execute: (String sql) -> void
13
- def schema_name: () -> Symbol
14
- end
15
- end
16
- end
17
- end