umbrellio-sequel-plugins 0.12.0.159 → 0.12.0.169
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a1f6f4eb4543668bd64fc9aaa0f666587d450eeb048bc3f20cb04d17d3cdfad
|
4
|
+
data.tar.gz: e2dd754b79b6a68d1eeddd8a282ec654db075c8f623793e8b454ad965358daba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22bfdde950888dff4767f1ed733fae0806f5336b00dc065f21be0917d218a02fe7a202ce72dcdea1f46863b06b9067c1aefa675fefedf9aff98270812b78ccda
|
7
|
+
data.tar.gz: 83fd34102711a4bb19bb67a7c912ae11f49cdbc346343fb0e98ae96fbc201476c68037c40699d0f53089208d0f5227221e96c5a046118a72a126a229c6893eb0
|
@@ -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
|
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.
|
4
|
+
version: 0.12.0.169
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Umbrellio
|
8
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
|