umbrellio-sequel-plugins 0.12.0.159 → 0.13.0

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: 142f01fd5727cf3e7e9e9f656679bc17e7aadd5935a11e0602a6dfa2aa9a37c9
4
- data.tar.gz: c3bf80f72c94ea9646fa8429de4e6af18a98757eb6c83f9928a32655f52c4321
3
+ metadata.gz: f29f65d03c79867897c8e08bc27130ee4ce4d20bf21ecbfc7e66c6bbdbe8d150
4
+ data.tar.gz: 6265fd9c0594c6d668d0398b6eafda76c74463d74a8bb0b99727826abc1b5b66
5
5
  SHA512:
6
- metadata.gz: 605ef2b5494a4918504a2f6c172b93f2691d6546949b26f0cad018b30aa1eaba470ee5b1b2434c58ddf545236c0d357bf66ecbe4be5e80ce9d6e7461f39b99e5
7
- data.tar.gz: 5a68bb15ddcc7a6526cbb208b703bd8de36b68ac0c4111e4f3d7a647c7cc5c74572900191080d8c97a7fc74e947abf9ac1ee3e512b12eb9664dc43734f4f2919
6
+ metadata.gz: d50a92b5db3b8c9cda5338ba92dcf427ac11dfc58d6cfe263ae1c10fe99e9c7e5069bea73830b74cf345216ae967a4fe8c3225f51a4d0143fb656caa7a306149
7
+ data.tar.gz: 553d918222554f431cf7ea54d6bf75cb31f41f5e7646e03d0e61b625700df103ed9fa38d3a671246728dbab44c1cadaf318f93eaadca06075f6c57e2585174ab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-sequel-plugins (0.12.0)
4
+ umbrellio-sequel-plugins (0.13.0)
5
5
  sequel
6
6
  symbiont-ruby
7
7
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :sequel do
4
+ desc "Archive migrations source code"
5
+ task archive_migrations: :environment do
6
+ DB.create_table?(:schema_migrations_sources) do
7
+ column :version, "numeric", primary_key: true
8
+ column :filename, "text", null: false
9
+ column :source, "text", null: false
10
+ end
11
+
12
+ migrations = Rails.root.glob("db/migrate/*.rb").map do |file|
13
+ filename = file.basename.to_s
14
+ { version: filename.to_i, filename: filename, source: file.read }
15
+ end
16
+
17
+ conflict_options = {
18
+ target: :version,
19
+ update: { source: Sequel[:excluded][:source] },
20
+ }
21
+
22
+ DB[:schema_migrations_sources].insert_conflict(**conflict_options).multi_insert(migrations)
23
+ end
24
+ end
@@ -7,20 +7,27 @@ namespace :sequel do
7
7
  task rollback_archived_migrations: :environment do
8
8
  DB.log_info("Finding applied migrations not present in current release...")
9
9
 
10
- archive_path = Pathname.new(ENV.fetch("ARCHIVE_PATH")).expand_path.join("db/migrate")
11
- migrator = Sequel::TimestampMigrator.new(DB, archive_path, allow_missing_migration_files: true)
10
+ Dir.mktmpdir do |tmpdir|
11
+ DB[:schema_migrations_sources].each do |migration|
12
+ path = File.join(tmpdir, migration.fetch(:filename))
13
+ File.write(path, migration.fetch(:source))
14
+ end
15
+
16
+ migrator = Sequel::TimestampMigrator.new(DB, tmpdir, allow_missing_migration_files: true)
12
17
 
13
- applied_migrations = migrator.applied_migrations.map(&:to_i)
14
- filesystem_migrations = Rails.root.glob("db/migrate/*.rb").map { |x| File.basename(x).to_i }
15
- missing_migrations = applied_migrations - filesystem_migrations
18
+ applied_migrations = migrator.applied_migrations.map(&:to_i)
19
+ filesystem_migrations = Rails.root.glob("db/migrate/*.rb").map { |x| File.basename(x).to_i }
20
+ missing_migrations = applied_migrations - filesystem_migrations
16
21
 
17
- if missing_migrations.any?
18
- missing_migrations.each do |migration|
19
- DB.log_info("Rolling back migration #{migration}...")
20
- migrator.undo(migration)
22
+ if missing_migrations.any?
23
+ missing_migrations.each do |migration|
24
+ DB.log_info("Rolling back migration #{migration}...")
25
+ migrator.undo(migration)
26
+ end
27
+ else
28
+ DB.log_info("No migrations found")
29
+ "No migrations found"
21
30
  end
22
- else
23
- DB.log_info("No migrations found")
24
31
  end
25
32
  end
26
33
  end
@@ -4,7 +4,7 @@ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- gem_version = "0.12.0"
7
+ gem_version = "0.13.0"
8
8
 
9
9
  if ENV.fetch("PUBLISH_JOB", nil)
10
10
  release_version = "#{gem_version}.#{ENV.fetch("GITHUB_RUN_NUMBER")}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-sequel-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0.159
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Umbrellio
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-11 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -75,6 +75,7 @@ files:
75
75
  - lib/sequel/plugins/upsert.rb
76
76
  - lib/sequel/plugins/with_lock.rb
77
77
  - lib/sequel/timestamp_migrator_undo_extension.rb
78
+ - lib/tasks/sequel/archive_migrations.rake
78
79
  - lib/tasks/sequel/rollback_archived_migrations.rake
79
80
  - lib/tasks/sequel/rollback_missing_migrations.rake
80
81
  - lib/tasks/sequel/undo.rake
@@ -88,7 +89,7 @@ homepage: https://github.com/umbrellio/umbrellio-sequel-plugins
88
89
  licenses:
89
90
  - MIT
90
91
  metadata: {}
91
- post_install_message:
92
+ post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
94
95
  - lib
@@ -103,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubygems_version: 3.3.5
107
- signing_key:
107
+ rubygems_version: 3.4.15
108
+ signing_key:
108
109
  specification_version: 4
109
110
  summary: Sequel plugins
110
111
  test_files: []