|
12 | 12 | depends_on = None |
13 | 13 |
|
14 | 14 | from alembic import op |
| 15 | +import sqlalchemy as sa |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def upgrade(): |
18 | 19 | ### commands auto generated by Alembic - please adjust! ### |
19 | 20 | conn = op.get_bind() |
20 | | - conn.execute('CREATE EXTENSION IF NOT EXISTS postgis;') |
21 | | - conn.execute('CREATE EXTENSION IF NOT EXISTS postgis_topology;') |
22 | | - conn.execute("SELECT AddGeometryColumn('public','markers','geom',4326,'POINT',2);") |
23 | | - conn.execute('UPDATE markers SET geom = ST_SetSRID(ST_MakePoint(longitude,latitude),4326);') |
24 | | - conn.execute('CREATE INDEX idx_markers_geom ON markers USING GIST(geom);') |
25 | | - conn.execute("SELECT AddGeometryColumn('public','discussions','geom',4326,'POINT',2);") |
26 | | - conn.execute('UPDATE discussions SET geom = ST_SetSRID(ST_MakePoint(longitude,latitude),4326);') |
27 | | - conn.execute('CREATE INDEX idx_discussions_geom ON discussions USING GIST(geom);') |
| 21 | + conn.execute(sa.text('CREATE EXTENSION IF NOT EXISTS postgis;')) |
| 22 | + conn.execute(sa.text('CREATE EXTENSION IF NOT EXISTS postgis_topology;')) |
| 23 | + conn.execute(sa.text("SELECT AddGeometryColumn('public','markers','geom',4326,'POINT',2);")) |
| 24 | + conn.execute(sa.text('UPDATE markers SET geom = ST_SetSRID(ST_MakePoint(longitude,latitude),4326);')) |
| 25 | + conn.execute(sa.text('CREATE INDEX idx_markers_geom ON markers USING GIST(geom);')) |
| 26 | + conn.execute(sa.text("SELECT AddGeometryColumn('public','discussions','geom',4326,'POINT',2);")) |
| 27 | + conn.execute(sa.text('UPDATE discussions SET geom = ST_SetSRID(ST_MakePoint(longitude,latitude),4326);')) |
| 28 | + conn.execute(sa.text('CREATE INDEX idx_discussions_geom ON discussions USING GIST(geom);')) |
28 | 29 |
|
29 | 30 | ### end Alembic commands ### |
30 | 31 |
|
31 | 32 |
|
32 | 33 | def downgrade(): |
33 | 34 | ### commands auto generated by Alembic - please adjust! ### |
34 | 35 | conn = op.get_bind() |
35 | | - conn.execute('DROP INDEX idx_markers_geom;') |
| 36 | + conn.execute(sa.text('DROP INDEX idx_markers_geom;')) |
36 | 37 | op.drop_column('markers', 'geom') |
37 | | - conn.execute('DROP INDEX idx_discussions_geom;') |
| 38 | + conn.execute(sa.text('DROP INDEX idx_discussions_geom;')) |
38 | 39 | op.drop_column('discussions', 'geom') |
39 | | - conn.execute('DROP EXTENSION postgis_topology;') |
40 | | - conn.execute('DROP EXTENSION postgis;') |
41 | | - conn.execute('DROP SCHEMA IF EXISTS topology CASCADE;') |
| 40 | + conn.execute(sa.text('DROP EXTENSION postgis_topology;')) |
| 41 | + conn.execute(sa.text('DROP EXTENSION postgis;')) |
| 42 | + conn.execute(sa.text('DROP SCHEMA IF EXISTS topology CASCADE;')) |
42 | 43 | ### end Alembic commands ### |
0 commit comments