Remove tags and categories table

This commit is contained in:
LoRiot 2022-10-17 13:56:54 +03:00
parent 4d5034204e
commit a01a00dec1
2 changed files with 35 additions and 20 deletions

View file

@ -0,0 +1,32 @@
"""add project contacts
Revision ID: 2450600b8eaf
Revises: 9b42b5289e30
Create Date: 2022-10-17 12:46:59.115251
"""
from alembic import op
from sqlalchemy.sql import text
# revision identifiers, used by Alembic.
revision = '2450600b8eaf'
down_revision = '9b42b5289e30'
branch_labels = None
depends_on = None
def upgrade() -> None:
conn = op.get_bind()
add_contacts_query = "ALTER TABLE projects ADD COLUMN contacts varchar(50)"
conn.execute(text(add_contacts_query))
def downgrade() -> None:
conn = op.get_bind()
drop_contacts_query = """
ALTER TABLE projects DROP COLUMN contacts
"""
conn.execute(text(drop_contacts_query))

View file

@ -6,7 +6,6 @@ Create Date: 2022-10-17 11:43:07.452838
""" """
from alembic import op from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import text from sqlalchemy.sql import text
@ -28,22 +27,6 @@ def upgrade() -> None:
""" """
conn.execute(text(init_users_query)) conn.execute(text(init_users_query))
init_tags_query = """
CREATE TABLE tags (
id SERIAL PRIMARY KEY,
name varchar(100)
);
"""
conn.execute(text(init_tags_query))
init_categories_query = """
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
name varchar(20)
);
"""
conn.execute(text(init_categories_query))
init_projects_query = """ init_projects_query = """
CREATE TABLE projects ( CREATE TABLE projects (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
@ -52,8 +35,8 @@ def upgrade() -> None:
creator bigint REFERENCES users, creator bigint REFERENCES users,
contributors smallint DEFAULT 1, contributors smallint DEFAULT 1,
status bit(1) DEFAULT B'1', status bit(1) DEFAULT B'1',
tag int REFERENCES tags, tag varchar(50) UNIQUE,
category int REFERENCES categories, category varchar(50) UNIQUE,
creation_date date DEFAULT CURRENT_DATE creation_date date DEFAULT CURRENT_DATE
); );
""" """
@ -64,5 +47,5 @@ def downgrade() -> None:
conn = op.get_bind() conn = op.get_bind()
conn.execute(text( conn.execute(text(
"DROP TABLE users, tags, categories, projects CASCADE" "DROP TABLE users, projects CASCADE"
)) ))