Incorporate database schema management #1

Open
opened 2026-06-25 15:29:53 +00:00 by eliribble · 1 comment
Owner

Currently schema management is done through strings and statements like:

            cur.execute("""
                CREATE TABLE IF NOT EXISTS test_plans (
                    id          SERIAL PRIMARY KEY,
                    key         TEXT UNIQUE NOT NULL,
                    title       TEXT NOT NULL,
                    description TEXT,
                    markdown    TEXT
                )
            """)

See an example

This is very brittle and makes it hard to keep track of schema. Instead, we should use a structured system like sqlalchemy-migrate which uses information in the database to apply migrations to change the database schema.

Currently schema management is done through strings and statements like: ``` cur.execute(""" CREATE TABLE IF NOT EXISTS test_plans ( id SERIAL PRIMARY KEY, key TEXT UNIQUE NOT NULL, title TEXT NOT NULL, description TEXT, markdown TEXT ) """) ``` See [an example](https://source.gleipnir.technology/Gleipnir/mechaturk/src/branch/main/backend/app.py#L151) This is very brittle and makes it hard to keep track of schema. Instead, we should use a structured system like [sqlalchemy-migrate](https://sqlalchemy-migrate.readthedocs.io/en/latest/versioning.html) which uses information in the database to apply migrations to change the database schema.

I would like to have a discusion on the app before I re-write all of the SQL again

I would like to have a discusion on the app before I re-write all of the SQL again
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Gleipnir/mechaturk#1
No description provided.