Remove unnecessary migrations
This commit is contained in:
parent
2640d1f417
commit
7528545054
4 changed files with 0 additions and 110 deletions
|
@ -1,31 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class CreateRelationTransitions < ActiveRecord::Migration[6.0]
|
|
||||||
include Partynest::Migration
|
|
||||||
|
|
||||||
def change
|
|
||||||
create_table :relation_transitions do |t|
|
|
||||||
t.timestamps null: false
|
|
||||||
|
|
||||||
t.references :from_status,
|
|
||||||
null: true,
|
|
||||||
foreign_key: { to_table: :relation_statuses }
|
|
||||||
|
|
||||||
t.references :to_status,
|
|
||||||
null: false,
|
|
||||||
foreign_key: { to_table: :relation_statuses }
|
|
||||||
|
|
||||||
t.string :name, null: false, index: { unique: true }
|
|
||||||
|
|
||||||
t.index %i[from_status_id to_status_id], unique: true
|
|
||||||
end
|
|
||||||
|
|
||||||
add_constraint :relation_transitions, :name, <<~SQL
|
|
||||||
is_good_small_text(name)
|
|
||||||
SQL
|
|
||||||
|
|
||||||
add_constraint :relation_transitions, :statuses, <<~SQL
|
|
||||||
from_status_id != to_status_id
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class UniqueIndexStatusesOnRelationTransitions < ActiveRecord::Migration[6.0]
|
|
||||||
def change
|
|
||||||
reversible do |dir|
|
|
||||||
dir.down do
|
|
||||||
execute <<~SQL
|
|
||||||
DROP INDEX
|
|
||||||
index_relation_transitions_on_to_status_id_when_from_status_id_is_null
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
|
|
||||||
dir.up do
|
|
||||||
execute <<~SQL
|
|
||||||
CREATE UNIQUE INDEX
|
|
||||||
index_relation_transitions_on_to_status_id_when_from_status_id_is_null
|
|
||||||
ON relation_transitions
|
|
||||||
USING btree
|
|
||||||
(to_status_id)
|
|
||||||
WHERE from_status_id IS NULL;
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,51 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class RemoveRelationTransitions < ActiveRecord::Migration[6.0]
|
|
||||||
include Partynest::Migration
|
|
||||||
|
|
||||||
def change
|
|
||||||
remove_constraint :relation_transitions, :name, <<~SQL
|
|
||||||
is_good_small_text(name)
|
|
||||||
SQL
|
|
||||||
|
|
||||||
remove_constraint :relation_transitions, :statuses, <<~SQL
|
|
||||||
from_status_id != to_status_id
|
|
||||||
SQL
|
|
||||||
|
|
||||||
reversible do |dir|
|
|
||||||
dir.up do
|
|
||||||
execute <<~SQL
|
|
||||||
DROP INDEX
|
|
||||||
index_relation_transitions_on_to_status_id_when_from_status_id_is_null
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
|
|
||||||
dir.down do
|
|
||||||
execute <<~SQL
|
|
||||||
CREATE UNIQUE INDEX
|
|
||||||
index_relation_transitions_on_to_status_id_when_from_status_id_is_null
|
|
||||||
ON relation_transitions
|
|
||||||
USING btree
|
|
||||||
(to_status_id)
|
|
||||||
WHERE from_status_id IS NULL;
|
|
||||||
SQL
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
drop_table :relation_transitions do |t|
|
|
||||||
t.timestamps null: false
|
|
||||||
|
|
||||||
t.references :from_status,
|
|
||||||
null: true,
|
|
||||||
foreign_key: { to_table: :relation_statuses }
|
|
||||||
|
|
||||||
t.references :to_status,
|
|
||||||
null: false,
|
|
||||||
foreign_key: { to_table: :relation_statuses }
|
|
||||||
|
|
||||||
t.string :name, null: false, index: { unique: true }
|
|
||||||
|
|
||||||
t.index %i[from_status_id to_status_id], unique: true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1880,7 +1880,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20181130024918'),
|
('20181130024918'),
|
||||||
('20190910040709'),
|
('20190910040709'),
|
||||||
('20190921142404'),
|
('20190921142404'),
|
||||||
('20190921161613'),
|
|
||||||
('20190921191213'),
|
('20190921191213'),
|
||||||
('20190928171705'),
|
('20190928171705'),
|
||||||
('20190929131544'),
|
('20190929131544'),
|
||||||
|
@ -1889,9 +1888,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20190930210852'),
|
('20190930210852'),
|
||||||
('20190930215223'),
|
('20190930215223'),
|
||||||
('20191001022049'),
|
('20191001022049'),
|
||||||
('20191001211809'),
|
|
||||||
('20191002002101'),
|
('20191002002101'),
|
||||||
('20191002113932'),
|
|
||||||
('20191002170727');
|
('20191002170727');
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue