From 34fc6c5ac3834c0001a76bee288a93b861c8cdba Mon Sep 17 00:00:00 2001 From: kompotkot Date: Wed, 16 Oct 2024 13:23:38 +0000 Subject: [PATCH] Set schema for version table --- moonstreamdb-v3/moonstreamdbv3/alembic/env.py | 3 +++ moonstreamdb-v3/moonstreamdbv3/models.py | 5 +++++ moonstreamdb-v3/moonstreamdbv3/version.txt | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py index 9dd671c1..082d718e 100644 --- a/moonstreamdb-v3/moonstreamdbv3/alembic/env.py +++ b/moonstreamdb-v3/moonstreamdbv3/alembic/env.py @@ -25,6 +25,7 @@ # my_important_option = config.get_main_option("my_important_option") # ... etc. from moonstreamdbv3.models import ( + MOONSTREAM_DB_V3_SCHEMA_NAME, AmoyLabel, ArbitrumNovaLabel, ArbitrumOneLabel, @@ -112,6 +113,7 @@ def run_migrations_offline() -> None: literal_binds=True, dialect_opts={"paramstyle": "named"}, version_table="alembic_version", + version_table_schema=MOONSTREAM_DB_V3_SCHEMA_NAME, include_schemas=True, include_symbol=include_symbol, ) @@ -138,6 +140,7 @@ def run_migrations_online() -> None: connection=connection, target_metadata=target_metadata, version_table="alembic_version", + version_table_schema=MOONSTREAM_DB_V3_SCHEMA_NAME, include_schemas=True, include_symbol=include_symbol, ) diff --git a/moonstreamdb-v3/moonstreamdbv3/models.py b/moonstreamdb-v3/moonstreamdbv3/models.py index 2a58501b..1547680b 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models.py +++ b/moonstreamdb-v3/moonstreamdbv3/models.py @@ -15,6 +15,7 @@ } """ +import os import uuid from sqlalchemy import ( @@ -56,6 +57,10 @@ 3. https://stackoverflow.com/a/33532154/13659585 """ +MOONSTREAM_DB_V3_SCHEMA_NAME = os.environ.get( + "MOONSTREAM_DB_V3_SCHEMA_NAME", "blockchain" +) + class utcnow(expression.FunctionElement): type = DateTime # type: ignore diff --git a/moonstreamdb-v3/moonstreamdbv3/version.txt b/moonstreamdb-v3/moonstreamdbv3/version.txt index fe04e7f6..236c7ad0 100644 --- a/moonstreamdb-v3/moonstreamdbv3/version.txt +++ b/moonstreamdb-v3/moonstreamdbv3/version.txt @@ -1 +1 @@ -0.0.20 +0.0.21