Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate alembic and add hg38 DB schema as initial revision #81

Merged
merged 8 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@
"build:web": "webpack --env prod",
"predist:python": "npm run build:python && npm run docs:python",
"prebuild:python": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test:python",
"prebuild:web": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test:web"
"prebuild:web": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test:web",
"db-migration": "cd ../tdp_core && npm run db-migration -- tdp_publicdb",
"db-migration:upgrade": "npm run db-migration -- upgrade",
"db-migration:upgrade:head": "npm run db-migration -- upgrade head",
"db-migration:downgrade": "npm run db-migration -- downgrade",
"db-migration:current": "npm run db-migration -- current",
"db-migration:history": "npm run db-migration -- history"
},
"main": "build/tdp_publicdb.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-e git+https://github.com/datavisyn/tdp_core.git@develop#egg=tdp_core
-e git+https://github.com/datavisyn/tdp_core.git@mp/291_db_migration#egg=tdp_core
psycopg2==2.8.3
7 changes: 7 additions & 0 deletions tdp_publicdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ def phovea(registry):
"""
# generator-phovea:begin
registry.append('tdp-sql-database-definition', 'publicdb', 'tdp_publicdb.sql', dict(configKey='tdp_publicdb'))

from os import path
registry.append('tdp-sql-database-migration', 'tdp_publicdb', '', {
'scriptLocation': path.join(path.abspath(path.dirname(__file__)), 'migration'),
'configKey': 'tdp_publicdb.migration',
'dbKey': 'publicdb'
})
# generator-phovea:end
pass

Expand Down
1 change: 1 addition & 0 deletions tdp_publicdb/migration/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Generic single-database configuration.
1 change: 1 addition & 0 deletions tdp_publicdb/migration/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import tdp_core.dbmigration_env # NOQA
24 changes: 24 additions & 0 deletions tdp_publicdb/migration/script.py.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""${message}

Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}

"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}

# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}


def upgrade():
${upgrades if upgrades else "pass"}


def downgrade():
${downgrades if downgrades else "pass"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""First_Revision

Revision ID: b477004c3673
Revises:
Create Date: 2020-03-02 13:12:59.636711

"""
from alembic import op
from codecs import open
import sqlalchemy as sa
from os import path

# revision identifiers, used by Alembic.
revision = 'b477004c3673'
down_revision = None
branch_labels = None
depends_on = None

# import the schema
here = path.relpath(path.dirname(__file__))
sql_file_path = path.join(here, './assets/ordino-schema-postgres12.sql')
thinkh marked this conversation as resolved.
Show resolved Hide resolved
ordino_hg38_schema = open(sql_file_path, mode='r').read()


def upgrade():
connection = op.get_bind()
# escape special characters before executing
connection.execute(sa.text(ordino_hg38_schema))
pass


def downgrade():
"""
"""
pass
Loading