Skip to content

Commit

Permalink
Update route for logs endpoint (revert back to older version); Comple…
Browse files Browse the repository at this point in the history
…ted fasl db migrate and upgrade
  • Loading branch information
satishsurath committed Feb 22, 2024
1 parent bba39d6 commit 162ea6a
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,8 +1370,8 @@ def logout():
return redirect(url_for('index'))

#rewriting the logs to show user's entries if session.get('name', False) is True
@app.route('/logs2', methods=['GET', 'POST'])
def logs2():
@app.route('/logs', methods=['GET', 'POST'])
def logs():
page = request.args.get('page', 1, type=int)
per_page = request.args.get('per_page', 25, type=int)

Expand Down Expand Up @@ -1433,8 +1433,8 @@ def logs2():

# Assuming Entry_Posts_History and Entry_Post models are defined with SQLAlchemy

@app.route('/logs', methods=['GET', 'POST'])
def logs():
@app.route('/logs2', methods=['GET', 'POST'])
def logs2():
page = request.args.get('page', 1, type=int)
per_page = request.args.get('per_page', 25, type=int)

Expand Down
122 changes: 122 additions & 0 deletions migrations/versions/0145da7deac4_some_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""Some message
Revision ID: 0145da7deac4
Revises: fa598c2c8d5e
Create Date: 2024-02-21 22:19:47.208955
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '0145da7deac4'
down_revision = 'fa598c2c8d5e'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('entry__posts__history', schema=None) as batch_op:
batch_op.add_column(sa.Column('oAuthUser_id', sa.Integer(), nullable=True))
batch_op.alter_column('timestamp',
existing_type=postgresql.TIMESTAMP(timezone=True),
type_=sa.DateTime(),
existing_nullable=True)
batch_op.drop_index('idx_29176_ix_entry__posts__history_entry_post_id')
batch_op.drop_index('idx_29176_ix_entry__posts__history_oauthuser_id')
batch_op.drop_index('idx_29176_ix_entry__posts__history_timestamp')
batch_op.create_index(batch_op.f('ix_entry__posts__history_entry_post_id'), ['entry_post_id'], unique=False)
batch_op.create_index(batch_op.f('ix_entry__posts__history_oAuthUser_id'), ['oAuthUser_id'], unique=False)
batch_op.create_index(batch_op.f('ix_entry__posts__history_timestamp'), ['timestamp'], unique=False)
batch_op.drop_constraint('entry__posts__history_ibfk_2', type_='foreignkey')
batch_op.create_foreign_key(None, 'o_auth_user', ['oAuthUser_id'], ['id'])
batch_op.drop_column('oauthuser_id')

with op.batch_alter_table('entry_post', schema=None) as batch_op:
batch_op.add_column(sa.Column('openAIsummary', sa.Text(), nullable=True))
batch_op.add_column(sa.Column('openAIkeyInsights', sa.Text(), nullable=True))
batch_op.add_column(sa.Column('openAItitle', sa.String(length=1024), nullable=True))
batch_op.alter_column('timestamp',
existing_type=postgresql.TIMESTAMP(timezone=True),
type_=sa.DateTime(),
existing_nullable=True)
batch_op.drop_index('idx_29181_ix_entry_post_posttype')
batch_op.drop_index('idx_29181_ix_entry_post_timestamp')
batch_op.drop_index('idx_29181_text2summarize_hash')
batch_op.create_index(batch_op.f('ix_entry_post_posttype'), ['posttype'], unique=False)
batch_op.create_index(batch_op.f('ix_entry_post_timestamp'), ['timestamp'], unique=False)
batch_op.create_unique_constraint(None, ['text2summarize_hash'])
batch_op.drop_column('openaikeyinsights')
batch_op.drop_column('openaisummary')
batch_op.drop_column('openaititle')

with op.batch_alter_table('o_auth_user', schema=None) as batch_op:
batch_op.alter_column('timestamp',
existing_type=postgresql.TIMESTAMP(timezone=True),
type_=sa.DateTime(),
existing_nullable=True)
batch_op.drop_index('idx_29188_ix_o_auth_user_email')
batch_op.drop_index('idx_29188_ix_o_auth_user_linkedin_id')
batch_op.drop_index('idx_29188_ix_o_auth_user_name')
batch_op.drop_index('idx_29188_ix_o_auth_user_timestamp')
batch_op.create_index(batch_op.f('ix_o_auth_user_email'), ['email'], unique=True)
batch_op.create_index(batch_op.f('ix_o_auth_user_linkedin_id'), ['linkedin_id'], unique=False)
batch_op.create_index(batch_op.f('ix_o_auth_user_name'), ['name'], unique=False)
batch_op.create_index(batch_op.f('ix_o_auth_user_timestamp'), ['timestamp'], unique=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('o_auth_user', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_o_auth_user_timestamp'))
batch_op.drop_index(batch_op.f('ix_o_auth_user_name'))
batch_op.drop_index(batch_op.f('ix_o_auth_user_linkedin_id'))
batch_op.drop_index(batch_op.f('ix_o_auth_user_email'))
batch_op.create_index('idx_29188_ix_o_auth_user_timestamp', ['timestamp'], unique=False)
batch_op.create_index('idx_29188_ix_o_auth_user_name', ['name'], unique=False)
batch_op.create_index('idx_29188_ix_o_auth_user_linkedin_id', ['linkedin_id'], unique=False)
batch_op.create_index('idx_29188_ix_o_auth_user_email', ['email'], unique=False)
batch_op.alter_column('timestamp',
existing_type=sa.DateTime(),
type_=postgresql.TIMESTAMP(timezone=True),
existing_nullable=True)

with op.batch_alter_table('entry_post', schema=None) as batch_op:
batch_op.add_column(sa.Column('openaititle', sa.VARCHAR(length=1024), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('openaisummary', sa.TEXT(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('openaikeyinsights', sa.TEXT(), autoincrement=False, nullable=True))
batch_op.drop_constraint(None, type_='unique')
batch_op.drop_index(batch_op.f('ix_entry_post_timestamp'))
batch_op.drop_index(batch_op.f('ix_entry_post_posttype'))
batch_op.create_index('idx_29181_text2summarize_hash', ['text2summarize_hash'], unique=False)
batch_op.create_index('idx_29181_ix_entry_post_timestamp', ['timestamp'], unique=False)
batch_op.create_index('idx_29181_ix_entry_post_posttype', ['posttype'], unique=False)
batch_op.alter_column('timestamp',
existing_type=sa.DateTime(),
type_=postgresql.TIMESTAMP(timezone=True),
existing_nullable=True)
batch_op.drop_column('openAItitle')
batch_op.drop_column('openAIkeyInsights')
batch_op.drop_column('openAIsummary')

with op.batch_alter_table('entry__posts__history', schema=None) as batch_op:
batch_op.add_column(sa.Column('oauthuser_id', sa.INTEGER(), autoincrement=False, nullable=True))
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.create_foreign_key('entry__posts__history_ibfk_2', 'o_auth_user', ['oauthuser_id'], ['id'])
batch_op.drop_index(batch_op.f('ix_entry__posts__history_timestamp'))
batch_op.drop_index(batch_op.f('ix_entry__posts__history_oAuthUser_id'))
batch_op.drop_index(batch_op.f('ix_entry__posts__history_entry_post_id'))
batch_op.create_index('idx_29176_ix_entry__posts__history_timestamp', ['timestamp'], unique=False)
batch_op.create_index('idx_29176_ix_entry__posts__history_oauthuser_id', ['oauthuser_id'], unique=False)
batch_op.create_index('idx_29176_ix_entry__posts__history_entry_post_id', ['entry_post_id'], unique=False)
batch_op.alter_column('timestamp',
existing_type=sa.DateTime(),
type_=postgresql.TIMESTAMP(timezone=True),
existing_nullable=True)
batch_op.drop_column('oAuthUser_id')

# ### end Alembic commands ###

0 comments on commit 162ea6a

Please sign in to comment.