diff --git a/migrations/versions/130cce777d35_.py b/migrations/versions/130cce777d35_.py index 487421d0..bddbc18f 100644 --- a/migrations/versions/130cce777d35_.py +++ b/migrations/versions/130cce777d35_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -42,16 +43,16 @@ def upgrade(): op.create_index(op.f('ix_ockovani_lide_kraj_bydl_nuts'), 'ockovani_lide', ['kraj_bydl_nuts'], unique=False) op.drop_column('ockovani_lide', 'kraj_nazev') connection = op.get_bind() - connection.execute("alter table ockovani_lide drop CONSTRAINT ockovani_lide_pkey") - connection.execute("alter table ockovani_lide add CONSTRAINT ockovani_lide_pkey PRIMARY KEY (datum, vakcina, zarizeni_kod, poradi_davky, vekova_skupina, kraj_bydl_nuts, indikace_bezpecnostni_infrastruktura, indikace_chronicke_onemocneni, indikace_ostatni, indikace_pedagog, indikace_skolstvi_ostatni, indikace_socialni_sluzby, indikace_zdravotnik)") + connection.execute(text("alter table ockovani_lide drop CONSTRAINT ockovani_lide_pkey")) + connection.execute(text("alter table ockovani_lide add CONSTRAINT ockovani_lide_pkey PRIMARY KEY (datum, vakcina, zarizeni_kod, poradi_davky, vekova_skupina, kraj_bydl_nuts, indikace_bezpecnostni_infrastruktura, indikace_chronicke_onemocneni, indikace_ostatni, indikace_pedagog, indikace_skolstvi_ostatni, indikace_socialni_sluzby, indikace_zdravotnik)")) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### connection = op.get_bind() - connection.execute("alter table ockovani_lide drop CONSTRAINT ockovani_lide_pkey") - connection.execute("alter table ockovani_lide add CONSTRAINT ockovani_lide_pkey PRIMARY KEY (datum, vakcina, zarizeni_kod, poradi_davky, vekova_skupina)") + connection.execute(text("alter table ockovani_lide drop CONSTRAINT ockovani_lide_pkey")) + connection.execute(text("alter table ockovani_lide add CONSTRAINT ockovani_lide_pkey PRIMARY KEY (datum, vakcina, zarizeni_kod, poradi_davky, vekova_skupina)")) op.add_column('ockovani_lide', sa.Column('kraj_nazev', sa.VARCHAR(), autoincrement=False, nullable=True)) op.drop_index(op.f('ix_ockovani_lide_kraj_bydl_nuts'), table_name='ockovani_lide') op.drop_column('ockovani_lide', 'kraj_bydl_nuts') diff --git a/migrations/versions/1ed9516441be_.py b/migrations/versions/1ed9516441be_.py index 1d7254c0..2b99144d 100644 --- a/migrations/versions/1ed9516441be_.py +++ b/migrations/versions/1ed9516441be_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -18,13 +19,13 @@ def upgrade(): connection = op.get_bind() - connection.execute("alter table ockovani_registrace add column ockovani smallint default -1") - connection.execute("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey") - connection.execute("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id, ockovani)") + connection.execute(text("alter table ockovani_registrace add column ockovani smallint default -1")) + connection.execute(text("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey")) + connection.execute(text("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id, ockovani)")) def downgrade(): connection = op.get_bind() - connection.execute("alter table ockovani_registrace drop column ockovani") - connection.execute("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey") - connection.execute("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id)") + connection.execute(text("alter table ockovani_registrace drop column ockovani")) + connection.execute(text("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey")) + connection.execute(text("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id)")) diff --git a/migrations/versions/5480e96df417_.py b/migrations/versions/5480e96df417_.py index 5f2b70f6..ffdcd8a4 100644 --- a/migrations/versions/5480e96df417_.py +++ b/migrations/versions/5480e96df417_.py @@ -6,7 +6,7 @@ """ from alembic import op -import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -18,15 +18,15 @@ def upgrade(): connection = op.get_bind() - connection.execute("DELETE FROM populace_kategorie WHERE vekova_skupina='0-17'") - connection.execute("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('0-11',0,11)") - connection.execute("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('12-15',12,15)") - connection.execute("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('16-17',16,17)") + connection.execute(text("DELETE FROM populace_kategorie WHERE vekova_skupina='0-17'")) + connection.execute(text("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('0-11',0,11)")) + connection.execute(text("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('12-15',12,15)")) + connection.execute(text("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('16-17',16,17)")) def downgrade(): connection = op.get_bind() - connection.execute("DELETE FROM populace_kategorie WHERE vekova_skupina='0-11'") - connection.execute("DELETE FROM populace_kategorie WHERE vekova_skupina='12-15'") - connection.execute("DELETE FROM populace_kategorie WHERE vekova_skupina='16-17'") - connection.execute("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('0-17',0,17)") + connection.execute(text("DELETE FROM populace_kategorie WHERE vekova_skupina='0-11'")) + connection.execute(text("DELETE FROM populace_kategorie WHERE vekova_skupina='12-15'")) + connection.execute(text("DELETE FROM populace_kategorie WHERE vekova_skupina='16-17'")) + connection.execute(text("INSERT INTO populace_kategorie (vekova_skupina,min_vek,max_vek) VALUES ('0-17',0,17)")) diff --git a/migrations/versions/6d30bda90e50_.py b/migrations/versions/6d30bda90e50_.py index 4df2638a..128639b8 100644 --- a/migrations/versions/6d30bda90e50_.py +++ b/migrations/versions/6d30bda90e50_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -18,7 +19,7 @@ def upgrade(): connection = op.get_bind() - connection.execute("update ockovani_lide set zarizeni_kod=lpad(zarizeni_kod,11,'0')") + connection.execute(text("update ockovani_lide set zarizeni_kod=lpad(zarizeni_kod,11,'0')")) def downgrade(): diff --git a/migrations/versions/b3623a352bec_.py b/migrations/versions/b3623a352bec_.py index 177dec75..bb74b52b 100644 --- a/migrations/versions/b3623a352bec_.py +++ b/migrations/versions/b3623a352bec_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -18,9 +19,9 @@ def upgrade(): connection = op.get_bind() - connection.execute("INSERT INTO ockovaci_mista (id, nazev, okres_id, status, nrpzs_kod) VALUES('4561f6a6-a019-4fb6-8552-6e15c74a3d04', 'EUC klinika Ostrava', 'CZ0806', false, '25860836000')") - connection.execute("INSERT INTO ockovaci_mista (id, nazev, okres_id, status, nrpzs_kod) VALUES('68fcce7d-b37b-4073-a8a0-c21a62976442', 'VITA, s.r.o.', 'CZ0426', false, '61537713000')") - connection.execute("INSERT INTO ockovaci_mista (id, nazev, okres_id, status, nrpzs_kod) VALUES('9d29801f-7265-47cc-abfc-0167f8f58b2d', 'HNsP Bílina', 'CZ0426', false, '61325422000')") + connection.execute(text("INSERT INTO ockovaci_mista (id, nazev, okres_id, status, nrpzs_kod) VALUES('4561f6a6-a019-4fb6-8552-6e15c74a3d04', 'EUC klinika Ostrava', 'CZ0806', false, '25860836000')")) + connection.execute(text("INSERT INTO ockovaci_mista (id, nazev, okres_id, status, nrpzs_kod) VALUES('68fcce7d-b37b-4073-a8a0-c21a62976442', 'VITA, s.r.o.', 'CZ0426', false, '61537713000')")) + connection.execute(text("INSERT INTO ockovaci_mista (id, nazev, okres_id, status, nrpzs_kod) VALUES('9d29801f-7265-47cc-abfc-0167f8f58b2d', 'HNsP Bílina', 'CZ0426', false, '61325422000')")) def downgrade(): pass diff --git a/migrations/versions/b8604a1102c8_.py b/migrations/versions/b8604a1102c8_.py index d0d74aa1..c820f1a6 100644 --- a/migrations/versions/b8604a1102c8_.py +++ b/migrations/versions/b8604a1102c8_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -18,9 +19,9 @@ def upgrade(): connection = op.get_bind() - connection.execute("update importy set date=start") - connection.execute("delete from importy where status='FAILED'") - connection.execute("delete from importy where id in (select id from importy except select max(id) from importy group by date)") + connection.execute(text("update importy set date=start")) + connection.execute(text("delete from importy where status='FAILED'")) + connection.execute(text("delete from importy where id in (select id from importy except select max(id) from importy group by date)")) def downgrade(): pass diff --git a/migrations/versions/b8e5763ba835_.py b/migrations/versions/b8e5763ba835_.py index 0803a326..707e6126 100644 --- a/migrations/versions/b8e5763ba835_.py +++ b/migrations/versions/b8e5763ba835_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -35,10 +36,10 @@ def upgrade(): # ### end Alembic commands ### connection = op.get_bind() - connection.execute("alter table ockovani_registrace add column pred_zavorou boolean default false") - connection.execute("alter table ockovani_registrace add column za_zavorou boolean default false") - connection.execute("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey") - connection.execute("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id, ockovani, pred_zavorou, za_zavorou)") + connection.execute(text("alter table ockovani_registrace add column pred_zavorou boolean default false")) + connection.execute(text("alter table ockovani_registrace add column za_zavorou boolean default false")) + connection.execute(text("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey")) + connection.execute(text("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id, ockovani, pred_zavorou, za_zavorou)")) def downgrade(): @@ -58,7 +59,7 @@ def downgrade(): # ### end Alembic commands ### connection = op.get_bind() - connection.execute("alter table ockovani_registrace drop column pred_zavorou") - connection.execute("alter table ockovani_registrace drop column za_zavorou") - connection.execute("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey") - connection.execute("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id, ockovani)") + connection.execute(text("alter table ockovani_registrace drop column pred_zavorou")) + connection.execute(text("alter table ockovani_registrace drop column za_zavorou")) + connection.execute(text("alter table ockovani_registrace drop CONSTRAINT ockovani_registrace_part_pkey")) + connection.execute(text("alter table ockovani_registrace add CONSTRAINT ockovani_registrace_part_pkey PRIMARY KEY (datum, ockovaci_misto_id, vekova_skupina, povolani, stat, rezervace, datum_rezervace, import_id, ockovani)")) diff --git a/migrations/versions/c703c687dcbf_.py b/migrations/versions/c703c687dcbf_.py index 583984d6..70400b2c 100644 --- a/migrations/versions/c703c687dcbf_.py +++ b/migrations/versions/c703c687dcbf_.py @@ -8,6 +8,7 @@ import pandas as pd from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -34,13 +35,13 @@ def upgrade(): ) connection = op.get_bind() - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Pfizer', 'Comirnaty', 2)") - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Moderna', 'COVID-19 Vaccine Moderna', 2)") - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('AstraZeneca', 'VAXZEVRIA', 2)") - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Janssen', 'COVID-19 Vaccine Janssen', 1)") - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Novavax', 'Novavax', 2)") - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('CureVac', 'CureVac', 2)") - connection.execute("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('GSK', 'GSK', 2)") + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Pfizer', 'Comirnaty', 2)")) + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Moderna', 'COVID-19 Vaccine Moderna', 2)")) + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('AstraZeneca', 'VAXZEVRIA', 2)")) + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Janssen', 'COVID-19 Vaccine Janssen', 1)")) + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('Novavax', 'Novavax', 2)")) + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('CureVac', 'CureVac', 2)")) + connection.execute(text("INSERT INTO vakciny (vyrobce, vakcina, davky) VALUES('GSK', 'GSK', 2)")) op.create_foreign_key(None, 'ockovani_distribuce', 'vakciny', ['vyrobce'], ['vyrobce']) op.create_foreign_key(None, 'ockovani_lide', 'vakciny', ['vakcina'], ['vakcina']) diff --git a/migrations/versions/cb94fb60af8b_.py b/migrations/versions/cb94fb60af8b_.py index fc9a8a10..913b319c 100644 --- a/migrations/versions/cb94fb60af8b_.py +++ b/migrations/versions/cb94fb60af8b_.py @@ -6,7 +6,7 @@ """ from alembic import op -import sqlalchemy as sa +from sqlalchemy import text import csv import urllib from app.models import ZdravotnickeStredisko @@ -23,7 +23,7 @@ def upgrade(): # ### end Alembic commands ### connection = op.get_bind() - connection.execute("truncate table zdravotnicke_stredisko") + connection.execute(text("truncate table zdravotnicke_stredisko")) url = "https://nrpzs.uzis.cz/res/file/export/export-2021-10.csv" response = urllib.request.urlopen(url) diff --git a/migrations/versions/d0ff680fad37_.py b/migrations/versions/d0ff680fad37_.py index 8b0a42f4..a5005f5c 100644 --- a/migrations/versions/d0ff680fad37_.py +++ b/migrations/versions/d0ff680fad37_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -18,7 +19,7 @@ def upgrade(): connection = op.get_bind() - connection.execute("update praktici_kapacity set adresa=split_part(adresa, ',', 1)") + connection.execute(text("update praktici_kapacity set adresa=split_part(adresa, ',', 1)")) def downgrade(): diff --git a/migrations/versions/dd9f6e3ad7c1_.py b/migrations/versions/dd9f6e3ad7c1_.py index 42d678e4..5dedde4d 100644 --- a/migrations/versions/dd9f6e3ad7c1_.py +++ b/migrations/versions/dd9f6e3ad7c1_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -24,8 +25,8 @@ def upgrade(): sa.PrimaryKeyConstraint('bezregistrace_id', 'cas_mereni') ) connection = op.get_bind() - connection.execute("truncate table ockovani_lide") - connection.execute("update vakciny set vakcina='Spikevax' where vyrobce='Moderna'") + connection.execute(text("truncate table ockovani_lide")) + connection.execute(text("update vakciny set vakcina='Spikevax' where vyrobce='Moderna'")) def downgrade(): diff --git a/migrations/versions/eb41821d2f4c_.py b/migrations/versions/eb41821d2f4c_.py index af1c2f84..62d48440 100644 --- a/migrations/versions/eb41821d2f4c_.py +++ b/migrations/versions/eb41821d2f4c_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -19,21 +20,21 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### connection = op.get_bind() - connection.execute("truncate table ockovani_rezervace") - connection.execute("alter table ockovani_rezervace drop CONSTRAINT if exists ockovani_rezervace_pkey") - connection.execute("alter table ockovani_rezervace drop CONSTRAINT if exists ockovani_rezervace_import_id_fkey") + connection.execute(text("truncate table ockovani_rezervace")) + connection.execute(text("alter table ockovani_rezervace drop CONSTRAINT if exists ockovani_rezervace_pkey")) + connection.execute(text("alter table ockovani_rezervace drop CONSTRAINT if exists ockovani_rezervace_import_id_fkey")) op.drop_column('ockovani_rezervace', 'import_id') - connection.execute("alter table ockovani_rezervace add CONSTRAINT ockovani_rezervace_pkey PRIMARY KEY (datum, ockovaci_misto_id, kalendar_ockovani)") + connection.execute(text("alter table ockovani_rezervace add CONSTRAINT ockovani_rezervace_pkey PRIMARY KEY (datum, ockovaci_misto_id, kalendar_ockovani)")) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### connection = op.get_bind() - connection.execute("truncate table ockovani_rezervace") - connection.execute("alter table ockovani_rezervace drop CONSTRAINT if exists ockovani_rezervace_pkey") + connection.execute(text("truncate table ockovani_rezervace")) + connection.execute(text("alter table ockovani_rezervace drop CONSTRAINT if exists ockovani_rezervace_pkey")) op.add_column('ockovani_rezervace', sa.Column('import_id', sa.INTEGER(), autoincrement=False, nullable=False)) op.create_foreign_key('ockovani_rezervace_import_id_fkey', 'ockovani_rezervace', 'importy', ['import_id'], ['id'], ondelete='CASCADE') - connection.execute("alter table ockovani_rezervace add CONSTRAINT ockovani_rezervace_pkey PRIMARY KEY (datum, ockovaci_misto_id, kalendar_ockovani, import_id)") + connection.execute(text("alter table ockovani_rezervace add CONSTRAINT ockovani_rezervace_pkey PRIMARY KEY (datum, ockovaci_misto_id, kalendar_ockovani, import_id)")) # ### end Alembic commands ### diff --git a/migrations/versions/f238461c71d7_.py b/migrations/versions/f238461c71d7_.py index 1394fddc..f8b9ab21 100644 --- a/migrations/versions/f238461c71d7_.py +++ b/migrations/versions/f238461c71d7_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -92,9 +93,9 @@ def upgrade(): op.drop_column('okresy_metriky', 'typ_metriky') op.drop_column('okresy_metriky', 'hodnota_int') connection = op.get_bind() - connection.execute("truncate table ockovaci_mista_metriky") - connection.execute("truncate table okresy_metriky") - connection.execute("truncate table kraje_metriky") + connection.execute(text("truncate table ockovaci_mista_metriky")) + connection.execute(text("truncate table okresy_metriky")) + connection.execute(text("truncate table kraje_metriky")) op.add_column('kraje_metriky', sa.Column('kraj_id', sa.Unicode(), nullable=False)) op.drop_constraint('kraje_metriky_id_fkey', 'kraje_metriky', type_='foreignkey') op.create_foreign_key(None, 'kraje_metriky', 'kraje', ['kraj_id'], ['id']) diff --git a/migrations/versions/f636a63c48d6_.py b/migrations/versions/f636a63c48d6_.py index e0396726..464ec6a7 100644 --- a/migrations/versions/f636a63c48d6_.py +++ b/migrations/versions/f636a63c48d6_.py @@ -7,6 +7,7 @@ """ from alembic import op import sqlalchemy as sa +from sqlalchemy import text # revision identifiers, used by Alembic. @@ -57,8 +58,8 @@ def upgrade(): op.drop_table('srovnani_ockovani') connection = op.get_bind() - connection.execute("truncate table ockovani_lide") - connection.execute("update vakciny set vakcina='SPIKEVAX' where vyrobce='Moderna'") + connection.execute(text("truncate table ockovani_lide")) + connection.execute(text("update vakciny set vakcina='SPIKEVAX' where vyrobce='Moderna'")) # ### end Alembic commands ###