Remove tags and categories table
This commit is contained in:
parent
4d5034204e
commit
a01a00dec1
32
alembic/versions/2450600b8eaf_add_project_contacts.py
Normal file
32
alembic/versions/2450600b8eaf_add_project_contacts.py
Normal 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))
|
|
@ -6,7 +6,6 @@ Create Date: 2022-10-17 11:43:07.452838
|
|||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
|
||||
|
@ -28,22 +27,6 @@ def upgrade() -> None:
|
|||
"""
|
||||
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 = """
|
||||
CREATE TABLE projects (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
@ -52,8 +35,8 @@ def upgrade() -> None:
|
|||
creator bigint REFERENCES users,
|
||||
contributors smallint DEFAULT 1,
|
||||
status bit(1) DEFAULT B'1',
|
||||
tag int REFERENCES tags,
|
||||
category int REFERENCES categories,
|
||||
tag varchar(50) UNIQUE,
|
||||
category varchar(50) UNIQUE,
|
||||
creation_date date DEFAULT CURRENT_DATE
|
||||
);
|
||||
"""
|
||||
|
@ -64,5 +47,5 @@ def downgrade() -> None:
|
|||
conn = op.get_bind()
|
||||
|
||||
conn.execute(text(
|
||||
"DROP TABLE users, tags, categories, projects CASCADE"
|
||||
"DROP TABLE users, projects CASCADE"
|
||||
))
|
||||
|
|
Reference in a new issue