fix: update database URL to use 0.0.0.0 and adjust Alembic migration configurations
This commit is contained in:
parent
ad6283680b
commit
6d9387d1b4
16
alembic.ini
16
alembic.ini
|
|
@ -1,30 +1,34 @@
|
||||||
[alembic]
|
[alembic]
|
||||||
script_location = migrations
|
script_location = migrations
|
||||||
|
file_template = %%(year)d%%(month)02d%%(day)02d_%%(hour)02d%%(minute)02d%%(second)d_%%(rev)s_%%(slug)s
|
||||||
prepend_sys_path = .
|
prepend_sys_path = .
|
||||||
|
|
||||||
# SQLAlchemy database URL is injected from app.core.config.Settings (see migrations/env.py).
|
|
||||||
sqlalchemy.url =
|
|
||||||
|
|
||||||
[loggers]
|
[loggers]
|
||||||
keys = root,sqlalchemy,alembic
|
keys = root,sqlalchemy,alembic
|
||||||
|
|
||||||
[handlers]
|
[handlers]
|
||||||
keys = console
|
keys = console
|
||||||
|
|
||||||
|
[post_write_hooks]
|
||||||
|
hooks = ruff
|
||||||
|
ruff.type = exec
|
||||||
|
ruff.executable = %(here)s/.venv/bin/ruff
|
||||||
|
ruff.options = format REVISION_SCRIPT_FILENAME
|
||||||
|
|
||||||
[formatters]
|
[formatters]
|
||||||
keys = generic
|
keys = generic
|
||||||
|
|
||||||
[logger_root]
|
[logger_root]
|
||||||
level = WARN
|
level = DEBUG
|
||||||
handlers = console
|
handlers = console
|
||||||
|
|
||||||
[logger_sqlalchemy]
|
[logger_sqlalchemy]
|
||||||
level = WARN
|
level = DEBUG
|
||||||
handlers =
|
handlers =
|
||||||
qualname = sqlalchemy.engine
|
qualname = sqlalchemy.engine
|
||||||
|
|
||||||
[logger_alembic]
|
[logger_alembic]
|
||||||
level = INFO
|
level = DEBUG
|
||||||
handlers = console
|
handlers = console
|
||||||
qualname = alembic
|
qualname = alembic
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class Settings(BaseSettings):
|
||||||
version: str = "0.1.0"
|
version: str = "0.1.0"
|
||||||
api_v1_prefix: str = "/api/v1"
|
api_v1_prefix: str = "/api/v1"
|
||||||
database_url: str = Field(
|
database_url: str = Field(
|
||||||
default="postgresql+asyncpg://postgres:postgres@localhost:5432/test_task_crm",
|
default="postgresql+asyncpg://postgres:postgres@0.0.0.0:5432/test_task_crm",
|
||||||
description="SQLAlchemy async connection string",
|
description="SQLAlchemy async connection string",
|
||||||
)
|
)
|
||||||
sqlalchemy_echo: bool = False
|
sqlalchemy_echo: bool = False
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ def run_migrations_offline() -> None:
|
||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
literal_binds=True,
|
literal_binds=True,
|
||||||
dialect_opts={"paramstyle": "named"},
|
dialect_opts={"paramstyle": "named"},
|
||||||
compare_type=True,
|
# compare_type=True,
|
||||||
compare_server_default=True,
|
# compare_server_default=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
|
@ -41,8 +41,8 @@ def do_run_migrations(connection: Connection) -> None:
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
compare_type=True,
|
# compare_type=True,
|
||||||
compare_server_default=True,
|
# compare_server_default=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
|
@ -67,12 +67,7 @@ async def run_migrations_online() -> None:
|
||||||
await connectable.dispose()
|
await connectable.dispose()
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
if context.is_offline_mode():
|
||||||
if context.is_offline_mode():
|
|
||||||
run_migrations_offline()
|
run_migrations_offline()
|
||||||
else:
|
else:
|
||||||
asyncio.run(run_migrations_online())
|
asyncio.run(run_migrations_online())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,38 @@ depends_on: tuple[str, ...] | None = None
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
organization_role = sa.Enum(
|
organization_role = sa.Enum(
|
||||||
"owner", "admin", "manager", "member", name="organization_role"
|
"owner",
|
||||||
|
"admin",
|
||||||
|
"manager",
|
||||||
|
"member",
|
||||||
|
name="organization_role",
|
||||||
|
create_type=False,
|
||||||
|
)
|
||||||
|
deal_status = sa.Enum(
|
||||||
|
"new",
|
||||||
|
"in_progress",
|
||||||
|
"won",
|
||||||
|
"lost",
|
||||||
|
name="deal_status",
|
||||||
|
create_type=False,
|
||||||
|
)
|
||||||
|
deal_stage = sa.Enum(
|
||||||
|
"qualification",
|
||||||
|
"proposal",
|
||||||
|
"negotiation",
|
||||||
|
"closed",
|
||||||
|
name="deal_stage",
|
||||||
|
create_type=False,
|
||||||
)
|
)
|
||||||
deal_status = sa.Enum("new", "in_progress", "won", "lost", name="deal_status")
|
|
||||||
deal_stage = sa.Enum("qualification", "proposal", "negotiation", "closed", name="deal_stage")
|
|
||||||
activity_type = sa.Enum(
|
activity_type = sa.Enum(
|
||||||
"comment", "status_changed", "task_created", "system", name="activity_type"
|
"comment",
|
||||||
|
"status_changed",
|
||||||
|
"task_created",
|
||||||
|
"system",
|
||||||
|
name="activity_type",
|
||||||
|
create_type=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
bind = op.get_bind()
|
|
||||||
organization_role.create(bind, checkfirst=True)
|
|
||||||
deal_status.create(bind, checkfirst=True)
|
|
||||||
deal_stage.create(bind, checkfirst=True)
|
|
||||||
activity_type.create(bind, checkfirst=True)
|
|
||||||
|
|
||||||
op.create_table(
|
op.create_table(
|
||||||
"organizations",
|
"organizations",
|
||||||
sa.Column("id", sa.Integer(), nullable=False),
|
sa.Column("id", sa.Integer(), nullable=False),
|
||||||
|
|
@ -212,12 +230,36 @@ def downgrade() -> None:
|
||||||
op.drop_table("organizations")
|
op.drop_table("organizations")
|
||||||
|
|
||||||
organization_role = sa.Enum(
|
organization_role = sa.Enum(
|
||||||
"owner", "admin", "manager", "member", name="organization_role"
|
"owner",
|
||||||
|
"admin",
|
||||||
|
"manager",
|
||||||
|
"member",
|
||||||
|
name="organization_role",
|
||||||
|
create_type=False,
|
||||||
|
)
|
||||||
|
deal_status = sa.Enum(
|
||||||
|
"new",
|
||||||
|
"in_progress",
|
||||||
|
"won",
|
||||||
|
"lost",
|
||||||
|
name="deal_status",
|
||||||
|
create_type=False,
|
||||||
|
)
|
||||||
|
deal_stage = sa.Enum(
|
||||||
|
"qualification",
|
||||||
|
"proposal",
|
||||||
|
"negotiation",
|
||||||
|
"closed",
|
||||||
|
name="deal_stage",
|
||||||
|
create_type=False,
|
||||||
)
|
)
|
||||||
deal_status = sa.Enum("new", "in_progress", "won", "lost", name="deal_status")
|
|
||||||
deal_stage = sa.Enum("qualification", "proposal", "negotiation", "closed", name="deal_stage")
|
|
||||||
activity_type = sa.Enum(
|
activity_type = sa.Enum(
|
||||||
"comment", "status_changed", "task_created", "system", name="activity_type"
|
"comment",
|
||||||
|
"status_changed",
|
||||||
|
"task_created",
|
||||||
|
"system",
|
||||||
|
name="activity_type",
|
||||||
|
create_type=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
bind = op.get_bind()
|
bind = op.get_bind()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue