Commit f8875891 authored by ras19's avatar ras19
Browse files

Made changes to database and generated migrations to reflect these changes [RS]

parent 573dc4b0
Pipeline #203250 passed with stage
in 1 minute and 21 seconds
"""empty message
Revision ID: 0bf2570a97ff
Revises: f5d42d08aad0
Create Date: 2021-06-16 08:13:15.381027
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0bf2570a97ff'
down_revision = 'f5d42d08aad0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('assigned_tasks', 'task_id',
existing_type=sa.INTEGER(),
nullable=False)
op.alter_column('assigned_tasks', 'username',
existing_type=sa.VARCHAR(),
nullable=False)
op.create_foreign_key(None, 'assigned_tasks', 'task', ['task_id'], ['id'])
op.create_foreign_key(None, 'assigned_tasks', 'user', ['username'], ['username'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'assigned_tasks', type_='foreignkey')
op.drop_constraint(None, 'assigned_tasks', type_='foreignkey')
op.alter_column('assigned_tasks', 'username',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('assigned_tasks', 'task_id',
existing_type=sa.INTEGER(),
nullable=True)
# ### end Alembic commands ###
"""empty message
Revision ID: 3cf62eb96987
Revises: b784652933b7
Create Date: 2021-06-16 07:53:30.916792
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3cf62eb96987'
down_revision = 'b784652933b7'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('assigned_tasks', 'task_id',
existing_type=sa.INTEGER(),
nullable=False)
op.alter_column('assigned_tasks', 'username',
existing_type=sa.VARCHAR(),
nullable=False)
op.create_foreign_key(None, 'assigned_tasks', 'user', ['username'], ['username'])
op.create_foreign_key(None, 'assigned_tasks', 'task', ['task_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'assigned_tasks', type_='foreignkey')
op.drop_constraint(None, 'assigned_tasks', type_='foreignkey')
op.alter_column('assigned_tasks', 'username',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('assigned_tasks', 'task_id',
existing_type=sa.INTEGER(),
nullable=True)
# ### end Alembic commands ###
"""empty message
Revision ID: f5d42d08aad0
Revises: 3cf62eb96987
Create Date: 2021-06-16 08:11:57.508998
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f5d42d08aad0'
down_revision = '3cf62eb96987'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('assigned_tasks', 'task_id',
existing_type=sa.INTEGER(),
nullable=False)
op.alter_column('assigned_tasks', 'username',
existing_type=sa.VARCHAR(),
nullable=False)
op.create_foreign_key(None, 'assigned_tasks', 'task', ['task_id'], ['id'])
op.create_foreign_key(None, 'assigned_tasks', 'user', ['username'], ['username'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'assigned_tasks', type_='foreignkey')
op.drop_constraint(None, 'assigned_tasks', type_='foreignkey')
op.alter_column('assigned_tasks', 'username',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('assigned_tasks', 'task_id',
existing_type=sa.INTEGER(),
nullable=True)
# ### end Alembic commands ###
......@@ -7,7 +7,7 @@ db = DB.the_database
class Task(db.Model):
description = db.Column(db.String)
priority = db.Column(db.Integer)
priority = db.Column(db.String)
completed = db.Column(db.Boolean)
due_date = db.Column(db.Date)
project_id = db.Column(db.Integer, ForeignKey('project.id'))
......@@ -35,8 +35,8 @@ class Task(db.Model):
)
class AssignedTasks(db.Model):
task_id = db.Column(db.Integer)
username = db.Column(db.String)
task_id = db.Column(db.Integer, ForeignKey('task.id'), nullable=False)
username = db.Column(db.String, ForeignKey('user.username'), nullable=False)
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
def save(self):
......
......@@ -6,7 +6,7 @@ from flask import jsonify
db = DB.the_database
class Todo(db.Model):
priority = db.Column(db.Integer)
priority = db.Column(db.String)
todo_desc = db.Column(db.String)
due_date = db.Column(db.Date)
username = db.Column(db.String, ForeignKey('user.username'))
......
......@@ -12,7 +12,7 @@ class User(db.Model):
title = db.Column(db.String)
email = db.Column(db.String)
bio = db.Column(db.String)
joined = db.Column(db.String)
joined = db.Column(db.Date)
location = db.Column(db.String)
availability = db.Column(db.String)
partnership_opportunities = db.Column(db.String)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment