-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from DocShow-AI/create_table_with_dataprofile
Create table with dataprofile
- Loading branch information
Showing
9 changed files
with
71 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[alembic] | ||
# ... other settings ... | ||
sqlalchemy.url = driver://user:pass@localhost/dummy | ||
sqlalchemy.url = postgresql://admin:[email protected]:5432/db | ||
script_location = alembic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,23 +7,43 @@ | |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
|
||
from models.base import Base # noqa: E402 | ||
from settings import APP_ENV, DATABASE_URL # noqa: E402 | ||
|
||
|
||
def run_migrations_online(): | ||
connectable = context.config.attributes.get("connection") | ||
|
||
# For app database | ||
if connectable is None: | ||
db_url = context.get_x_argument(as_dictionary=True).get("db", None) | ||
if db_url: | ||
connectable = engine_from_config( | ||
context.config.get_section(context.config.config_ini_section), | ||
prefix="sqlalchemy.", | ||
poolclass=pool.NullPool, | ||
url=db_url, | ||
) | ||
# Run migrations for app database | ||
with connectable.connect() as connection: | ||
context.configure(connection=connection, target_metadata=Base) | ||
with context.begin_transaction(): | ||
context.run_migrations() | ||
if APP_ENV == "dev": | ||
db_url = "postgresql://admin:[email protected]:5432/db" | ||
else: | ||
db_url = DATABASE_URL | ||
connectable = engine_from_config( | ||
context.config.get_section(context.config.config_ini_section), | ||
prefix="sqlalchemy.", | ||
poolclass=pool.NullPool, | ||
url=db_url, | ||
) | ||
# Run migrations for app database | ||
with connectable.connect() as connection: | ||
context.configure(connection=connection, target_metadata=Base) | ||
with context.begin_transaction(): | ||
context.run_migrations() | ||
|
||
|
||
def run_migrations_offline(): | ||
context.configure(url=DATABASE_URL) | ||
|
||
with context.begin_transaction(): | ||
context.run_migrations() | ||
|
||
|
||
def run_migrations(): | ||
if context.is_offline_mode(): | ||
run_migrations_offline() | ||
else: | ||
run_migrations_online() | ||
|
||
|
||
run_migrations() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.