safer_migrations 0.1.0 → 0.1.1

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: 6ad6bd8008a2d391b97b18ec2c14b12a51a35c875c34b0cfa2f61ec079ed89b9
4
- data.tar.gz: c5892a3dfd9646c4c1d8b38a7538189f056b1deb771d6302220efde903eec311
3
+ metadata.gz: 14751619b1434778cf62af64f5aa0959435662ae20b7e24d9e86262a8891577e
4
+ data.tar.gz: 50632544c70e28d5a30caf13e71f9a3ee31d4ae3a97ed68c92da62cab18fc7e8
5
5
  SHA512:
6
- metadata.gz: 6b7d30166b71ad5a053f5fdcef23ee166004e5867867cd841fbf133cf517666c27e3289203e5936cc4f17f3bdbfbdc0ca74c7110809b2d380cb2658a1c952b9b
7
- data.tar.gz: 12e0ba7df956e5678ffa13bc4cbc8851f0265017e3c2498da953d60bff02f55f1384f4272fda52b4cc298da28650f1256d275a8cf3928ecf41acc05aeb6e1c02
6
+ metadata.gz: b1b2bf84f85d427b85786e87d28b4d2a0cda533f541c9aaf416f54078f03c3651fd0535bd035270f023436b38decc98212474ad8de7494825594d4f27ffdbbee
7
+ data.tar.gz: e54e1374995bd0a8f0f951fe9a3d6d04d444b03c8391a3f9e4b4b9e71c4440a4440132a606a63d759f84557b7c1304974786d45ba9875cf079c09eb2fbc346a6
@@ -17,5 +17,13 @@ module SaferMigrations
17
17
  def invert_safer_remove_columns(args)
18
18
  invert_remove_columns(args)
19
19
  end
20
+
21
+ ruby2_keywords def safer_rename_column(*args, &block)
22
+ record(:safer_rename_column, args, &block)
23
+ end
24
+
25
+ def invert_safer_rename_column(args)
26
+ invert_rename_column(args)
27
+ end
20
28
  end
21
29
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SaferMigrations
4
+ module TableDefinition
5
+ def safer_remove(*column_names, **options)
6
+ @base.safer_remove_columns(name, *column_names, **options)
7
+ end
8
+
9
+ def safer_rename(column_name, new_column_name)
10
+ @base.safer_rename_column(name, column_name, new_column_name)
11
+ end
12
+ end
13
+ end
@@ -14,6 +14,11 @@ module SaferMigrations
14
14
  remove_columns(table_name, *column_names, type = nil, **options)
15
15
  end
16
16
 
17
+ def safer_rename_column(table_name, column_name, new_column_name)
18
+ validate_remove_column(table_name, column_name)
19
+ rename_column(table_name, column_name, new_column_name)
20
+ end
21
+
17
22
  private
18
23
 
19
24
  def validate_remove_column(table_name, column_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SaferMigrations
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -7,8 +7,10 @@ require_relative "safer_migrations/version"
7
7
  require_relative "safer_migrations/errors"
8
8
  require_relative "safer_migrations/command_recorder"
9
9
  require_relative "safer_migrations/schema_statements"
10
+ require_relative "safer_migrations/schema_definitions"
10
11
 
11
12
  ActiveSupport.on_load(:active_record) do
12
13
  ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(SaferMigrations::SchemaStatements)
14
+ ActiveRecord::ConnectionAdapters::Table.prepend(SaferMigrations::TableDefinition)
13
15
  ActiveRecord::Migration::CommandRecorder.prepend(SaferMigrations::CommandRecorder)
14
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safer_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji yaginuma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-30 00:00:00.000000000 Z
11
+ date: 2024-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -51,6 +51,7 @@ files:
51
51
  - lib/safer_migrations.rb
52
52
  - lib/safer_migrations/command_recorder.rb
53
53
  - lib/safer_migrations/errors.rb
54
+ - lib/safer_migrations/schema_definitions.rb
54
55
  - lib/safer_migrations/schema_statements.rb
55
56
  - lib/safer_migrations/version.rb
56
57
  homepage: https://github.com/y-yagi