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]
|
||||
script_location = migrations
|
||||
file_template = %%(year)d%%(month)02d%%(day)02d_%%(hour)02d%%(minute)02d%%(second)d_%%(rev)s_%%(slug)s
|
||||
prepend_sys_path = .
|
||||
|
||||
# SQLAlchemy database URL is injected from app.core.config.Settings (see migrations/env.py).
|
||||
sqlalchemy.url =
|
||||
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[post_write_hooks]
|
||||
hooks = ruff
|
||||
ruff.type = exec
|
||||
ruff.executable = %(here)s/.venv/bin/ruff
|
||||
ruff.options = format REVISION_SCRIPT_FILENAME
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
level = DEBUG
|
||||
handlers = console
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
level = DEBUG
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
level = DEBUG
|
||||
handlers = console
|
||||
qualname = alembic
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Settings(BaseSettings):
|
|||
version: str = "0.1.0"
|
||||
api_v1_prefix: str = "/api/v1"
|
||||
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",
|
||||
)
|
||||
sqlalchemy_echo: bool = False
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ def run_migrations_offline() -> None:
|
|||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
compare_type=True,
|
||||
compare_server_default=True,
|
||||
# compare_type=True,
|
||||
# compare_server_default=True,
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
|
|
@ -41,8 +41,8 @@ def do_run_migrations(connection: Connection) -> None:
|
|||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
compare_type=True,
|
||||
compare_server_default=True,
|
||||
# compare_type=True,
|
||||
# compare_server_default=True,
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
|
|
@ -67,12 +67,7 @@ async def run_migrations_online() -> None:
|
|||
await connectable.dispose()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
asyncio.run(run_migrations_online())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
asyncio.run(run_migrations_online())
|
||||
|
|
|
|||
|
|
@ -13,20 +13,38 @@ depends_on: tuple[str, ...] | None = None
|
|||
|
||||
def upgrade() -> None:
|
||||
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(
|
||||
"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(
|
||||
"organizations",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
|
|
@ -212,12 +230,36 @@ def downgrade() -> None:
|
|||
op.drop_table("organizations")
|
||||
|
||||
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(
|
||||
"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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue