Browse Source

migrations work properly

master
Juni Kim 2 years ago
parent
commit
4fb59e676f
  1. 12
      2-5-23.txt
  2. 5
      entrypoint.sh
  3. 56
      migrations/versions/1a0a82192181_.py
  4. 1
      validate.py

12
2-5-23.txt

@ -1,12 +0,0 @@
# Changes to Make
- Show how to make a network request in R to the server
- Version Control (what date a compound was added)
- createdAt, but configurable. DONE
- Compare the database to the list of compunds and you only want compounds
from that date or before? DONE
- Emphasizing Local? - Accessible through a url. DONE, all fields accessible.
- Shiny app
- Permissions System (revoke, access API keys)

5
entrypoint.sh

@ -2,7 +2,6 @@
set -x
#flask db upgrade
./initialize_db.py
#gunicorn -b 0.0.0.0:5000 'app.__init__.create_app()' --chdir /app
cd /app || exit
flask db upgrade
gunicorn -b 0.0.0.0:5000 app:app --chdir /app

56
migrations/versions/1a0a82192181_.py

@ -0,0 +1,56 @@
"""empty message
Revision ID: 1a0a82192181
Revises: 7e9528cf1416
Create Date: 2023-04-11 19:01:00.565936
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1a0a82192181'
down_revision = '7e9528cf1416'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('chemical', schema=None) as batch_op:
batch_op.add_column(sa.Column('person_name', sa.String(), nullable=False))
batch_op.add_column(sa.Column('standard_grp', sa.String(), nullable=False))
batch_op.add_column(sa.Column('metabolite_name', sa.String(), nullable=False))
batch_op.alter_column('inchikey',
existing_type=sa.VARCHAR(),
nullable=False)
batch_op.alter_column('final_adduct',
existing_type=sa.VARCHAR(),
nullable=False)
batch_op.alter_column('msms_detected',
existing_type=sa.BOOLEAN(),
nullable=False)
batch_op.drop_column('name')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('chemical', schema=None) as batch_op:
batch_op.add_column(sa.Column('name', sa.VARCHAR(), nullable=False))
batch_op.alter_column('msms_detected',
existing_type=sa.BOOLEAN(),
nullable=True)
batch_op.alter_column('final_adduct',
existing_type=sa.VARCHAR(),
nullable=True)
batch_op.alter_column('inchikey',
existing_type=sa.VARCHAR(),
nullable=True)
batch_op.drop_column('metabolite_name')
batch_op.drop_column('standard_grp')
batch_op.drop_column('person_name')
# ### end Alembic commands ###

1
validate.py

@ -90,7 +90,6 @@ def validate_insertion_csv_fields(reader: csv.DictReader) -> tuple[list[dict], s
chemicals: list[dict] = []
for row in reader:
chemical = {}
print("row", row)
for field, t in _required_fields:
if field not in row:
return [], f"Required field \"{field}\" not present in csv"

Loading…
Cancel
Save