Commit 7c0abf69 authored by ras19's avatar ras19
Browse files

Updating repo with two database development [RS, EW]

parents eb8d2ad1 b020fbd9
......@@ -8,6 +8,7 @@ test-job:
- apt-get update -qy
- apt-get install -y python3 python3-pip
- pip3 install -r requirements.txt
- export ENV="dev"
- python3 run_tests.py test
heroku-deploy:
......@@ -18,6 +19,7 @@ heroku-deploy:
- apt-get install -y python3 python3-pip
- pip3 install -r requirements.txt
- pip3 install python-dotenv
- export ENV="prod"
- cd backend
- python3 -m flask db upgrade
- cd ..
......
import os
from flask import Flask, render_template
from flask_migrate import Migrate
from backend.database_config.database import DB
......@@ -6,6 +7,8 @@ from backend.blueprints.user import user
from backend.blueprints.todo import todo
from backend.blueprints.task import task
ENV = os.environ.get("ENV")
app = Flask(__name__)
app.register_blueprint(project)
......@@ -15,7 +18,11 @@ app.register_blueprint(task)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://g205001034_u:CierkbZMND@db.doc.ic.ac.uk:5432/g205001034_u'
if ENV == 'dev':
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://g205001034_u:CierkbZMND@db.doc.ic.ac.uk:5432/g205001034_u'
else:
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://icbwsbzlctcxyx:a0d7f73e5b743a35f33d95640b517b6e7e9e5b59cd2ff10673e90372b4b34d44@ec2-34-193-112-164.compute-1.amazonaws.com:5432/deje5qriuvrh39'
db = DB.the_database
db.app = app
......
Generic single-database configuration.
\ No newline at end of file
"""empty message
Revision ID: 8e16378bae7e
Revises: 8aca5c725ce9
Create Date: 2021-06-09 12:17:43.767146
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8e16378bae7e'
down_revision = '8aca5c725ce9'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('assigned_tasks',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('task',
sa.Column('description', sa.String(), nullable=True),
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('completed', sa.Boolean(), nullable=True),
sa.Column('due_date', sa.Date(), nullable=True),
sa.Column('project_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_table('project_tasks')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('project_tasks',
sa.Column('project_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('task_id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('task_id', name='project_tasks_pkey')
)
op.drop_table('task')
op.drop_table('assigned_tasks')
# ### end Alembic commands ###
"""empty message
Revision ID: 8aca5c725ce9
Revises: ec68c4b5813f
Create Date: 2021-06-09 11:08:45.680961
Revision ID: b784652933b7
Revises:
Create Date: 2021-06-13 18:29:25.146966
"""
from alembic import op
......@@ -10,14 +10,20 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8aca5c725ce9'
down_revision = 'ec68c4b5813f'
revision = 'b784652933b7'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('assigned_tasks',
sa.Column('task_id', sa.Integer(), nullable=True),
sa.Column('username', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('project',
sa.Column('name', sa.String(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
......@@ -28,11 +34,6 @@ def upgrade():
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('project_tasks',
sa.Column('project_id', sa.Integer(), nullable=True),
sa.Column('task_id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('task_id')
)
op.create_table('user',
sa.Column('firstname', sa.String(), nullable=True),
sa.Column('surname', sa.String(), nullable=True),
......@@ -48,9 +49,20 @@ def upgrade():
sa.Column('username', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('username')
)
op.create_table('task',
sa.Column('description', sa.String(), nullable=True),
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('completed', sa.Boolean(), nullable=True),
sa.Column('due_date', sa.Date(), nullable=True),
sa.Column('project_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('todo',
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('todo_desc', sa.String(), nullable=True),
sa.Column('due_date', sa.Date(), nullable=True),
sa.Column('username', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['username'], ['user.username'], ),
......@@ -71,7 +83,8 @@ def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_project')
op.drop_table('todo')
op.drop_table('task')
op.drop_table('user')
op.drop_table('project_tasks')
op.drop_table('project')
op.drop_table('assigned_tasks')
# ### end Alembic commands ###
"""empty message
Revision ID: ca3946ceea1a
Revises: d1228461a0cb
Create Date: 2021-06-10 20:54:00.983912
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ca3946ceea1a'
down_revision = 'd1228461a0cb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('todo', sa.Column('due_date', sa.Date(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('todo', 'due_date')
# ### end Alembic commands ###
"""empty message
Revision ID: d1228461a0cb
Revises: 8e16378bae7e
Create Date: 2021-06-10 07:54:01.889263
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd1228461a0cb'
down_revision = '8e16378bae7e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('assigned_tasks', sa.Column('task_id', sa.Integer(), nullable=True))
op.add_column('assigned_tasks', sa.Column('username', sa.String(), nullable=True))
op.add_column('todo', sa.Column('due_date', sa.Date(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('todo', 'due_date')
op.drop_column('assigned_tasks', 'username')
op.drop_column('assigned_tasks', 'task_id')
# ### end Alembic commands ###
"""empty message
Revision ID: ec68c4b5813f
Revises: f9b4de0c3aa1
Create Date: 2021-06-09 10:56:15.003900
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ec68c4b5813f'
down_revision = 'f9b4de0c3aa1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('project',
sa.Column('name', sa.String(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('tag', sa.String(), nullable=True),
sa.Column('location', sa.String(), nullable=True),
sa.Column('files', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('project_tasks',
sa.Column('project_id', sa.Integer(), nullable=True),
sa.Column('task_id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('task_id')
)
op.create_table('todo',
sa.Column('priority', sa.Integer(), nullable=True),
sa.Column('todo_desc', sa.String(), nullable=True),
sa.Column('username', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('firstname', sa.String(), nullable=True),
sa.Column('surname', sa.String(), nullable=True),
sa.Column('password', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('email', sa.String(), nullable=True),
sa.Column('bio', sa.String(), nullable=True),
sa.Column('joined', sa.String(), nullable=True),
sa.Column('location', sa.String(), nullable=True),
sa.Column('availability', sa.String(), nullable=True),
sa.Column('partnership_opportunities', sa.String(), nullable=True),
sa.Column('interests', sa.String(), nullable=True),
sa.Column('username', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('username')
)
op.create_table('user_project',
sa.Column('username', sa.String(), nullable=False),
sa.Column('project_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
sa.ForeignKeyConstraint(['username'], ['user.username'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_project')
op.drop_table('user')
op.drop_table('todo')
op.drop_table('project_tasks')
op.drop_table('project')
# ### end Alembic commands ###
"""empty message
Revision ID: f9b4de0c3aa1
Revises:
Create Date: 2021-06-09 10:50:54.643012
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f9b4de0c3aa1'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('project',
sa.Column('name', sa.String(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('tag', sa.String(), nullable=True),
sa.Column('location', sa.String(), nullable=True),
sa.Column('files', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('project_tasks',
sa.Column('project_id', sa.Integer(), nullable=True),
sa.Column('task_id', sa.Integer(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('task_id')
)
op.create_table('user',
sa.Column('firstname', sa.String(), nullable=True),
sa.Column('surname', sa.String(), nullable=True),
sa.Column('password', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('email', sa.String(), nullable=True),
sa.Column('bio', sa.String(), nullable=True),
sa.Column('joined', sa.String(), nullable=True),
sa.Column('location', sa.String(), nullable=True),
sa.Column('availability', sa.String(), nullable=True),
sa.Column('partnership_opportunities', sa.String(), nullable=True),
sa.Column('interests', sa.String(), nullable=True),
sa.Column('username', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('username')
)
op.create_table('user_project',
sa.Column('username', sa.String(), nullable=False),
sa.Column('project_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
sa.ForeignKeyConstraint(['username'], ['user.username'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_project')
op.drop_table('user')
op.drop_table('project_tasks')
op.drop_table('project')
# ### end Alembic commands ###
......@@ -3,5 +3,5 @@ python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
pip install Flask python-dotenv
export DATABASE_URL='postgres://g205001034_u:CierkbZMND@db.doc.ic.ac.uk:5432/g205001034_u'
export ENV="dev"
gunicorn backend.wsgi
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