capture_migration_sql 1.0.3 → 1.0.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: e9d0592f093cdbe9554321bc75518d3af78810d3ed24b96c2f4914d326e5c991
4
- data.tar.gz: 0ab138c8d223536e39724814947a4ddccee7dac377ec14b9544aed4d759a77c0
3
+ metadata.gz: '09a2f079879c03ed186a9ee307884faf19826e2f67b9424cd4848322588a3be0'
4
+ data.tar.gz: cdc45945a17614ff25f89332fd1fba71872549e190cac1f7d61cd2fedff77a84
5
5
  SHA512:
6
- metadata.gz: 48a1b618e0815a6e7644435e277b935a2e5bf65d0bb6188d7126404a83dd0cad90e17b1c1d9de675c01bae1a7119f5ab68772fb0e662dbd57e63ac8f517070b7
7
- data.tar.gz: 9d311ca2aed3e266723741e5b95970fba37a3c9f133a4315b6e45d063991dd4411355a3f508f8cb3eb85527df6e179b0de177a21de9de9220f18f1981f6e6d9c
6
+ metadata.gz: 8dd9031cfb5a8e72f94892b6626f3ea8918d75729d4997178b32dbeb53813d6969056bb0634b5f6989bf98a78579952e832819a01ef85655259182f726f97313
7
+ data.tar.gz: 02a0bff93314e8a73dd6f8408a8c8e8f81ec93f5498aae72fdd3ddcb5306bd863c4d05d9da3e68c9af035156d29bf2f8edd4b8cf060b09cd1b3335011be73b5c
data/CHANGELOG.md CHANGED
@@ -4,22 +4,32 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 1.0.4
8
+
9
+ ### Fixed
10
+
11
+ - SQL files are now removed when they were created from a failed migration.
12
+
7
13
  ## 1.0.3
8
14
 
9
15
  ### Changed
10
- * SQL files will not be changed if they already exist.
16
+
17
+ - SQL files will not be changed if they already exist.
11
18
 
12
19
  ## 1.0.2
13
20
 
14
21
  ### Changed
15
- * Fix data type for insterting into schema_migrations
22
+
23
+ - Fix data type for insterting into schema_migrations
16
24
 
17
25
  ## 1.0.1
18
26
 
19
27
  ### Changed
20
- * Fix SQL for insterting into schema_migrations
28
+
29
+ - Fix SQL for insterting into schema_migrations
21
30
 
22
31
  ## 1.0.0
23
32
 
24
33
  ### Added
25
- * Initial release
34
+
35
+ - Initial release
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # CaptureMigrationSql
1
+ # Capture Migration SQL
2
2
 
3
3
  [![Continuous Integration](https://github.com/bdurand/capture_migration_sql/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/bdurand/capture_migration_sql/actions/workflows/continuous_integration.yml)
4
+ [![Regression Test](https://github.com/bdurand/capture_migration_sql/actions/workflows/regression_test.yml/badge.svg)](https://github.com/bdurand/capture_migration_sql/actions/workflows/regression_test.yml)
4
5
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
6
+ [![Gem Version](https://badge.fury.io/rb/capture_migration_sql.svg)](https://badge.fury.io/rb/capture_migration_sql)
5
7
 
6
8
  This gem adds the ability to capture and persist the SQL statements executed by migrations. There are a couple of reasons why you may want to do this.
7
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  gemfiles/
22
22
  spec/
23
23
  ]
24
- spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
24
+ spec.files = Dir.chdir(__dir__) do
25
25
  `git ls-files -z`.split("\x0").reject { |f| ignore_files.any? { |path| f.start_with?(path) } }
26
26
  end
27
27
 
@@ -30,4 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "activerecord", ">= 4.2"
31
31
 
32
32
  spec.add_development_dependency "bundler"
33
+
34
+ spec.required_ruby_version = ">= 2.5"
33
35
  end
@@ -75,22 +75,33 @@ module CaptureMigrationSql
75
75
  else
76
76
  Dir.mkdir(migration_sql_dir) unless File.exist?(migration_sql_dir)
77
77
  SqlSubscriber.attach_if_necessary
78
+ retval = nil
79
+ success = false
78
80
  File.open(output_file, "w") do |f|
79
- f.write("--\n-- #{name} : #{version}\n--\n\n")
80
- save_stream = Thread.current[:capture_migration_sql_stream]
81
- begin
82
- Thread.current[:capture_migration_sql_stream] = f
83
- sql_logging(enabled: true, &block)
84
- ensure
85
- Thread.current[:capture_migration_sql_stream] = save_stream
86
- end
87
- f.write("INSERT INTO schema_migrations (version) VALUES ('#{version.to_i}');\n")
81
+ retval = capture_migration_sql(f, &block)
82
+ success = true
83
+ ensure
84
+ File.unlink(output_file) unless success
88
85
  end
86
+ retval
89
87
  end
90
88
  else
91
89
  File.unlink(output_file) if output_file && File.exist?(output_file)
92
90
  yield
93
91
  end
94
92
  end
93
+
94
+ def capture_migration_sql(f, &block)
95
+ f.write("--\n-- #{name} : #{version}\n--\n\n")
96
+ save_stream = Thread.current[:capture_migration_sql_stream]
97
+ begin
98
+ Thread.current[:capture_migration_sql_stream] = f
99
+ retval = sql_logging(enabled: true, &block)
100
+ ensure
101
+ Thread.current[:capture_migration_sql_stream] = save_stream
102
+ end
103
+ f.write("INSERT INTO schema_migrations (version) VALUES ('#{version.to_i}');\n")
104
+ retval
105
+ end
95
106
  end
96
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capture_migration_sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2024-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - bbdurand@gmail.com
44
44
  executables: []
@@ -58,7 +58,7 @@ homepage: https://github.com/bdurand/capture_migration_sql
58
58
  licenses:
59
59
  - MIT
60
60
  metadata: {}
61
- post_install_message:
61
+ post_install_message:
62
62
  rdoc_options: []
63
63
  require_paths:
64
64
  - lib
@@ -66,15 +66,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: '2.5'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.1.6
77
- signing_key:
76
+ rubygems_version: 3.4.12
77
+ signing_key:
78
78
  specification_version: 4
79
79
  summary: Capture the SQL that is executed when running ActiveRecord migrations so
80
80
  that it can be run in in other environments that don't support migrations.