spina-blocks 0.1.3 → 0.2.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/db/migrate/20250101000001_create_spina_blocks_categories.rb +16 -0
- data/db/migrate/20250101000002_create_spina_blocks_blocks.rb +16 -0
- data/db/migrate/20250101000003_create_spina_blocks_page_blocks.rb +16 -0
- data/db/migrate/20250101000004_remove_name_from_spina_blocks_blocks.rb +16 -0
- data/lib/spina/blocks/version.rb +1 -1
- metadata +1 -2
- data/db/migrate/20250101000000_update_spina_blocks_migration_versions.rb +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08e197d3a0201be80942ea3c1807a1c538312e4ca58ddf9cc0c8ce08f39a0c05'
|
|
4
|
+
data.tar.gz: 04ae851acfdbfbecf0f30486748f0283b9afa9d18c0bb8f03cde8f83fec21450
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4606d45194c8fabe89c79f51a8129af1d1fb8043ec07e6601a65c3c2d5f59997c475904ee04088f6966b3a56652584c20c41c0fb15433d22589b445373276af1
|
|
7
|
+
data.tar.gz: cb7906b60e6100513d8e637759074e0e7ed6968a7a18deaa7a6b3806b93c86853efc9df43fdc0461e3c025d78f8070f6db2546bec0a60ab766929909b9440c2b
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
class CreateSpinaBlocksCategories < ActiveRecord::Migration[7.0]
|
|
4
4
|
def change
|
|
5
|
+
if legacy_migration_applied?
|
|
6
|
+
cleanup_legacy_version!
|
|
7
|
+
return
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
create_table :spina_blocks_categories do |t|
|
|
6
11
|
t.string :name, null: false
|
|
7
12
|
t.string :label, null: false
|
|
@@ -12,4 +17,15 @@ class CreateSpinaBlocksCategories < ActiveRecord::Migration[7.0]
|
|
|
12
17
|
|
|
13
18
|
add_index :spina_blocks_categories, :name, unique: true
|
|
14
19
|
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def legacy_migration_applied?
|
|
24
|
+
ActiveRecord::Base.connection
|
|
25
|
+
.select_value("SELECT 1 FROM schema_migrations WHERE version = '1'")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def cleanup_legacy_version!
|
|
29
|
+
execute "DELETE FROM schema_migrations WHERE version = '1'"
|
|
30
|
+
end
|
|
15
31
|
end
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
class CreateSpinaBlocksBlocks < ActiveRecord::Migration[7.0]
|
|
4
4
|
def change
|
|
5
|
+
if legacy_migration_applied?
|
|
6
|
+
cleanup_legacy_version!
|
|
7
|
+
return
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
create_table :spina_blocks_blocks do |t|
|
|
6
11
|
t.string :title, null: false
|
|
7
12
|
t.string :name, null: false
|
|
@@ -16,4 +21,15 @@ class CreateSpinaBlocksBlocks < ActiveRecord::Migration[7.0]
|
|
|
16
21
|
|
|
17
22
|
add_index :spina_blocks_blocks, :name, unique: true
|
|
18
23
|
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def legacy_migration_applied?
|
|
28
|
+
ActiveRecord::Base.connection
|
|
29
|
+
.select_value("SELECT 1 FROM schema_migrations WHERE version = '2'")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def cleanup_legacy_version!
|
|
33
|
+
execute "DELETE FROM schema_migrations WHERE version = '2'"
|
|
34
|
+
end
|
|
19
35
|
end
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
class CreateSpinaBlocksPageBlocks < ActiveRecord::Migration[7.0]
|
|
4
4
|
def change
|
|
5
|
+
if legacy_migration_applied?
|
|
6
|
+
cleanup_legacy_version!
|
|
7
|
+
return
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
create_table :spina_blocks_page_blocks do |t|
|
|
6
11
|
t.references :page, null: false, foreign_key: { to_table: :spina_pages }
|
|
7
12
|
t.references :block, null: false, foreign_key: { to_table: :spina_blocks_blocks }
|
|
@@ -12,4 +17,15 @@ class CreateSpinaBlocksPageBlocks < ActiveRecord::Migration[7.0]
|
|
|
12
17
|
|
|
13
18
|
add_index :spina_blocks_page_blocks, %i[page_id block_id], unique: true
|
|
14
19
|
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def legacy_migration_applied?
|
|
24
|
+
ActiveRecord::Base.connection
|
|
25
|
+
.select_value("SELECT 1 FROM schema_migrations WHERE version = '3'")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def cleanup_legacy_version!
|
|
29
|
+
execute "DELETE FROM schema_migrations WHERE version = '3'"
|
|
30
|
+
end
|
|
15
31
|
end
|
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
class RemoveNameFromSpinaBlocksBlocks < ActiveRecord::Migration[7.0]
|
|
4
4
|
def change
|
|
5
|
+
if legacy_migration_applied?
|
|
6
|
+
cleanup_legacy_version!
|
|
7
|
+
return
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
remove_index :spina_blocks_blocks, :name
|
|
6
11
|
remove_column :spina_blocks_blocks, :name, :string
|
|
7
12
|
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def legacy_migration_applied?
|
|
17
|
+
ActiveRecord::Base.connection
|
|
18
|
+
.select_value("SELECT 1 FROM schema_migrations WHERE version = '4'")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def cleanup_legacy_version!
|
|
22
|
+
execute "DELETE FROM schema_migrations WHERE version = '4'"
|
|
23
|
+
end
|
|
8
24
|
end
|
data/lib/spina/blocks/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spina-blocks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Konstantin Kanashchuk
|
|
@@ -63,7 +63,6 @@ files:
|
|
|
63
63
|
- app/views/spina/blocks/admin/page_blocks/index.html.erb
|
|
64
64
|
- config/locales/en.yml
|
|
65
65
|
- config/routes.rb
|
|
66
|
-
- db/migrate/20250101000000_update_spina_blocks_migration_versions.rb
|
|
67
66
|
- db/migrate/20250101000001_create_spina_blocks_categories.rb
|
|
68
67
|
- db/migrate/20250101000002_create_spina_blocks_blocks.rb
|
|
69
68
|
- db/migrate/20250101000003_create_spina_blocks_page_blocks.rb
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class UpdateSpinaBlocksMigrationVersions < ActiveRecord::Migration[7.0]
|
|
4
|
-
VERSIONS_MAPPING = {
|
|
5
|
-
'1' => '20250101000001',
|
|
6
|
-
'2' => '20250101000002',
|
|
7
|
-
'3' => '20250101000003',
|
|
8
|
-
'4' => '20250101000004'
|
|
9
|
-
}.freeze
|
|
10
|
-
|
|
11
|
-
def up
|
|
12
|
-
VERSIONS_MAPPING.each do |old_version, new_version|
|
|
13
|
-
execute <<~SQL.squish
|
|
14
|
-
UPDATE schema_migrations
|
|
15
|
-
SET version = '#{new_version}'
|
|
16
|
-
WHERE version = '#{old_version}'
|
|
17
|
-
SQL
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def down
|
|
22
|
-
# no-op: reverting to numbered migrations is not supported
|
|
23
|
-
end
|
|
24
|
-
end
|