This commit is contained in:
Kenneth Kehl
2023-08-29 14:54:30 -07:00
parent 19dcd7a48b
commit 1ecb747c6d
588 changed files with 34091 additions and 23580 deletions
@@ -9,28 +9,32 @@ from alembic import op
import sqlalchemy as sa
revision = '0260_remove_dvla_organisation'
down_revision = '0259_remove_service_postage'
revision = "0260_remove_dvla_organisation"
down_revision = "0259_remove_service_postage"
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('services', 'dvla_organisation_id')
op.drop_column('services_history', 'dvla_organisation_id')
op.drop_table('dvla_organisation')
op.drop_column("services", "dvla_organisation_id")
op.drop_column("services_history", "dvla_organisation_id")
op.drop_table("dvla_organisation")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('dvla_organisation',
sa.Column('id', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
sa.Column('filename', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('id', name='dvla_organisation_pkey')
op.create_table(
"dvla_organisation",
sa.Column("id", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=False),
sa.Column(
"filename", sa.VARCHAR(length=255), autoincrement=False, nullable=False
),
sa.PrimaryKeyConstraint("id", name="dvla_organisation_pkey"),
)
# can't repopulate the services, but we can put the static data back in dvla_organisation
op.execute("""
op.execute(
"""
INSERT INTO dvla_organisation VALUES
('001', 'HM Government', 'hm-government'),
('002', 'Office of the Public Guardian', 'opg'),
@@ -73,12 +77,47 @@ def downgrade():
('528', 'North Yorkshire Council', 'north-yorkshire'),
('529', 'Redbridge Council', 'redbridge'),
('530', 'Wigan Council', 'wigan')
""")
"""
)
op.add_column('services_history', sa.Column('dvla_organisation_id', sa.VARCHAR(), server_default=sa.text("'001'::character varying"), autoincrement=False, nullable=False))
op.add_column('services', sa.Column('dvla_organisation_id', sa.VARCHAR(), server_default=sa.text("'001'::character varying"), autoincrement=False, nullable=False))
op.add_column(
"services_history",
sa.Column(
"dvla_organisation_id",
sa.VARCHAR(),
server_default=sa.text("'001'::character varying"),
autoincrement=False,
nullable=False,
),
)
op.add_column(
"services",
sa.Column(
"dvla_organisation_id",
sa.VARCHAR(),
server_default=sa.text("'001'::character varying"),
autoincrement=False,
nullable=False,
),
)
op.create_index('ix_services_history_dvla_organisation_id', 'services_history', ['dvla_organisation_id'], unique=False)
op.create_foreign_key('services_dvla_organisation_id_fkey', 'services', 'dvla_organisation', ['dvla_organisation_id'], ['id'])
op.create_index('ix_services_dvla_organisation_id', 'services', ['dvla_organisation_id'], unique=False)
op.create_index(
"ix_services_history_dvla_organisation_id",
"services_history",
["dvla_organisation_id"],
unique=False,
)
op.create_foreign_key(
"services_dvla_organisation_id_fkey",
"services",
"dvla_organisation",
["dvla_organisation_id"],
["id"],
)
op.create_index(
"ix_services_dvla_organisation_id",
"services",
["dvla_organisation_id"],
unique=False,
)
# ### end Alembic commands ###