Skip to content

Commit 0f0d613

Browse files
committed
Migration for shelterluv_animals table
1 parent 35d4bd3 commit 0f0d613

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""empty message
2+
3+
Revision ID: 9687db7928ee
4+
Revises: a3ba63dee8f4
5+
Create Date: 2021-12-24 21:15:33.399197
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '9687db7928ee'
14+
down_revision = 'a3ba63dee8f4'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
op.create_table (
21+
"shelterluv_animals",
22+
sa.Column("id", sa.BigInteger, primary_key=True),
23+
sa.Column("local_id", sa.BigInteger, nullable=False),
24+
sa.Column("name", sa.Text, nullable=False),
25+
sa.Column("type", sa.Text, nullable=False),
26+
sa.Column("dob", sa.BigInteger, nullable=False),
27+
sa.Column("update_stamp", sa.BigInteger, nullable=False),
28+
sa.Column("photo", sa.Text, nullable=False)
29+
)
30+
31+
32+
def downgrade():
33+
op.drop_table("shelterluv_animals")

src/server/api/API_ingest/shelterluv_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def insert_animals(animal_list):
2424
sla = Table("shelterluv_animals", metadata, autoload=True, autoload_with=engine)
2525

2626
# From Shelterluv: ['ID', 'Internal-ID', 'Name', 'Type', 'DOBUnixTime', 'CoverPhoto', 'LastUpdatedUnixTime']
27-
# In db: ['local_id', 'id' (PK), 'name', 'type', 'dob', 'photo', 'updatestamp']
27+
# In db: ['local_id', 'id' (PK), 'name', 'type', 'dob', 'photo', 'update_stamp']
2828

2929
ins_list = [] # Create a list of per-row dicts
3030
for rec in animal_list:
@@ -35,7 +35,7 @@ def insert_animals(animal_list):
3535
"name": rec["Name"],
3636
"type": rec["Type"],
3737
"dob": rec["DOBUnixTime"],
38-
"updatestamp": rec["LastUpdatedUnixTime"],
38+
"update_stamp": rec["LastUpdatedUnixTime"],
3939
"photo": rec["CoverPhoto"],
4040
}
4141
)

0 commit comments

Comments
 (0)