Skip to content

problems creating alembic migrations #2

@stealthrabbi

Description

@stealthrabbi

Hello,

What is the path for creating alembic migrations? If I do it on my host machine. First, I had to add the following lines to env.py, so alembic could find the model files:

import sys

sys.path = ['', '..'] + sys.path[1:]

Then, if i try to generate migrations on my host, i get issues that all the POSTGRES variables are missing:

alembic revision --autogenerate -m "test migration"

...
pydantic.error_wrappers.ValidationError: 8 validation errors for Settings
SERVER_NAME
  field required (type=value_error.missing)
PROJECT_NAME
  field required (type=value_error.missing)
POSTGRES_SCHEME
  field required (type=value_error.missing)
POSTGRES_SERVER
  field required (type=value_error.missing)
POSTGRES_USER
  field required (type=value_error.missing)
POSTGRES_PASSWORD
  field required (type=value_error.missing)
POSTGRES_DB
  field required (type=value_error.missing)
SQLALCHEMY_DATABASE_URI
  unsupported operand type(s) for +: 'NoneType' and 'str' (type=type_error)

If I exec in to my app container and run the migration there, I get connection issues:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?
        

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions