Fix PostgreSQL sequence start values
This commit is contained in:
parent
15cf8f0449
commit
bf2d93229f
2 changed files with 18 additions and 4 deletions
|
@ -5,6 +5,7 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
|||
change_types
|
||||
change_functions
|
||||
change_tables
|
||||
change_sequences
|
||||
change_constraints
|
||||
change_triggers
|
||||
end
|
||||
|
@ -357,6 +358,19 @@ private
|
|||
end
|
||||
end
|
||||
|
||||
def change_sequences
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
execute <<~SQL
|
||||
ALTER SEQUENCE contact_networks_id_seq START WITH 100;
|
||||
ALTER SEQUENCE federal_subjects_id_seq START WITH 100;
|
||||
ALTER SEQUENCE contacts_id_seq START WITH 4000;
|
||||
ALTER SEQUENCE people_id_seq START WITH 3000;
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def change_constraints
|
||||
constraint :contacts, :value, <<~SQL
|
||||
is_good_small_text(value)
|
||||
|
|
|
@ -423,7 +423,7 @@ CREATE TABLE public.contact_networks (
|
|||
--
|
||||
|
||||
CREATE SEQUENCE public.contact_networks_id_seq
|
||||
START WITH 1
|
||||
START WITH 100
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
|
@ -457,7 +457,7 @@ CREATE TABLE public.contacts (
|
|||
--
|
||||
|
||||
CREATE SEQUENCE public.contacts_id_seq
|
||||
START WITH 1
|
||||
START WITH 4000
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
|
@ -496,7 +496,7 @@ CREATE TABLE public.federal_subjects (
|
|||
--
|
||||
|
||||
CREATE SEQUENCE public.federal_subjects_id_seq
|
||||
START WITH 1
|
||||
START WITH 100
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
|
@ -606,7 +606,7 @@ CREATE TABLE public.people (
|
|||
--
|
||||
|
||||
CREATE SEQUENCE public.people_id_seq
|
||||
START WITH 1
|
||||
START WITH 3000
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
|
|
Reference in a new issue