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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tasks/sequel/archive_migrations.rake +24 -0
- data/lib/tasks/sequel/rollback_archived_migrations.rake +18 -11
- data/umbrellio-sequel-plugins.gemspec +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f29f65d03c79867897c8e08bc27130ee4ce4d20bf21ecbfc7e66c6bbdbe8d150
|
4
|
+
data.tar.gz: 6265fd9c0594c6d668d0398b6eafda76c74463d74a8bb0b99727826abc1b5b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d50a92b5db3b8c9cda5338ba92dcf427ac11dfc58d6cfe263ae1c10fe99e9c7e5069bea73830b74cf345216ae967a4fe8c3225f51a4d0143fb656caa7a306149
|
7
|
+
data.tar.gz: 553d918222554f431cf7ea54d6bf75cb31f41f5e7646e03d0e61b625700df103ed9fa38d3a671246728dbab44c1cadaf318f93eaadca06075f6c57e2585174ab
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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.
|
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.
|
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
|
+
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.
|
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: []
|