From 6e8e4cb4ec6d542bd60390920eedf1c76b5dc8b5 Mon Sep 17 00:00:00 2001 From: tchawou-daniel Date: Sun, 17 Jan 2021 23:40:22 +0100 Subject: [PATCH] :wrench: update config.yml --- .circleci/config.yml | 5 +- conduit/settings.py | 6 +- migrations/versions/1fdc5b147c03_.py | 24 +++++++ migrations/versions/7d3571718539_.py | 101 +++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 migrations/versions/1fdc5b147c03_.py create mode 100644 migrations/versions/7d3571718539_.py diff --git a/.circleci/config.yml b/.circleci/config.yml index f19a336..835d8b0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,8 @@ jobs: command: | . venv/bin/activate sleep 1 - flask db migrate -m "Initial migration." + flask db init + flask db migrate flask db upgrade - run: name: flask test @@ -94,4 +95,4 @@ workflows: - start_test - buildandpush_dockerhub: requires: - - build \ No newline at end of file + - back-deploy-heroku \ No newline at end of file diff --git a/conduit/settings.py b/conduit/settings.py index c0315c0..df74152 100644 --- a/conduit/settings.py +++ b/conduit/settings.py @@ -38,7 +38,7 @@ class ProdConfig(Config): ENV = 'prod' DEBUG = False SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', - 'postgresql://localhost/example') + 'postgres://zzwfxxyjttqvvv:5c9ab87c7ae70f140b89de5a5e9aef30eed531d57fdce32e3e6723c252a3e210@ec2-18-208-49-190.compute-1.amazonaws.com:5432/d6p87lud6gi5r') class DevConfig(Config): @@ -47,7 +47,7 @@ class DevConfig(Config): ENV = 'dev' DEBUG = True SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', - 'postgresql://localhost/example') + 'postgres://zzwfxxyjttqvvv:5c9ab87c7ae70f140b89de5a5e9aef30eed531d57fdce32e3e6723c252a3e210@ec2-18-208-49-190.compute-1.amazonaws.com:5432/d6p87lud6gi5r') CACHE_TYPE = 'simple' # Can be "memcached", "redis", etc. JWT_ACCESS_TOKEN_EXPIRES = timedelta(10 ** 6) @@ -58,6 +58,6 @@ class TestConfig(Config): TESTING = True DEBUG = True SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', - 'postgresql://localhost/example') + 'postgres://zzwfxxyjttqvvv:5c9ab87c7ae70f140b89de5a5e9aef30eed531d57fdce32e3e6723c252a3e210@ec2-18-208-49-190.compute-1.amazonaws.com:5432/d6p87lud6gi5r') # For faster tests; needs at least 4 to avoid "ValueError: Invalid rounds" BCRYPT_LOG_ROUNDS = 4 diff --git a/migrations/versions/1fdc5b147c03_.py b/migrations/versions/1fdc5b147c03_.py new file mode 100644 index 0000000..ca9ec75 --- /dev/null +++ b/migrations/versions/1fdc5b147c03_.py @@ -0,0 +1,24 @@ +"""empty message + +Revision ID: 1fdc5b147c03 +Revises: 2267f00a4594 +Create Date: 2021-01-17 23:38:32.056745 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1fdc5b147c03' +down_revision = '2267f00a4594' +branch_labels = None +depends_on = None + + +def upgrade(): + pass + + +def downgrade(): + pass diff --git a/migrations/versions/7d3571718539_.py b/migrations/versions/7d3571718539_.py new file mode 100644 index 0000000..d112af1 --- /dev/null +++ b/migrations/versions/7d3571718539_.py @@ -0,0 +1,101 @@ +"""empty message + +Revision ID: 7d3571718539 +Revises: 1fdc5b147c03 +Create Date: 2021-01-17 23:38:42.568747 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7d3571718539' +down_revision = '1fdc5b147c03' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('tags', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('tagname', sa.String(length=100), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('users', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('username', sa.String(length=80), nullable=False), + sa.Column('email', sa.String(length=100), nullable=False), + sa.Column('password', sa.Binary(), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=False), + sa.Column('updated_at', sa.DateTime(), nullable=False), + sa.Column('bio', sa.String(length=300), nullable=True), + sa.Column('image', sa.String(length=120), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('email'), + sa.UniqueConstraint('username') + ) + op.create_table('userprofile', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('user_id') + ) + op.create_table('article', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('slug', sa.Text(), nullable=True), + sa.Column('title', sa.String(length=100), nullable=False), + sa.Column('description', sa.Text(), nullable=False), + sa.Column('body', sa.Text(), nullable=True), + sa.Column('createdAt', sa.DateTime(), nullable=False), + sa.Column('updatedAt', sa.DateTime(), nullable=False), + sa.Column('author_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['author_id'], ['userprofile.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('slug') + ) + op.create_table('followers_assoc', + sa.Column('follower', sa.Integer(), nullable=True), + sa.Column('followed_by', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['followed_by'], ['userprofile.user_id'], ), + sa.ForeignKeyConstraint(['follower'], ['userprofile.user_id'], ) + ) + op.create_table('comment', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('body', sa.Text(), nullable=True), + sa.Column('createdAt', sa.DateTime(), nullable=False), + sa.Column('updatedAt', sa.DateTime(), nullable=False), + sa.Column('author_id', sa.Integer(), nullable=False), + sa.Column('article_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['article_id'], ['article.id'], ), + sa.ForeignKeyConstraint(['author_id'], ['userprofile.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('favoritor_assoc', + sa.Column('favoriter', sa.Integer(), nullable=True), + sa.Column('favorited_article', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['favorited_article'], ['article.id'], ), + sa.ForeignKeyConstraint(['favoriter'], ['userprofile.id'], ) + ) + op.create_table('tag_assoc', + sa.Column('tag', sa.Integer(), nullable=True), + sa.Column('article', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['article'], ['article.id'], ), + sa.ForeignKeyConstraint(['tag'], ['tags.id'], ) + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('tag_assoc') + op.drop_table('favoritor_assoc') + op.drop_table('comment') + op.drop_table('followers_assoc') + op.drop_table('article') + op.drop_table('userprofile') + op.drop_table('users') + op.drop_table('tags') + # ### end Alembic commands ###