Closed purplesmoke05 closed 1 year ago
Close: #1377
redefine table schemas so that they have preferable primary keys.
position
executable_contract
idx_position_bond_block_number
idx_position_share_block_number
idx_position_coupon_block_number
idx_position_membership_block_number
Fixed some GROUP BY queries in APIs which contains dropped columns in this PR.
app/api/routers/position.py
app/api/routers/token.py
Added migration downgrade test.
Close: #1377
Changes
redefine table schemas so that they have preferable primary keys.
position
executable_contract
idx_position_bond_block_number
idx_position_share_block_number
idx_position_coupon_block_number
idx_position_membership_block_number
Fixed some GROUP BY queries in APIs which contains dropped columns in this PR.
app/api/routers/position.py
app/api/routers/token.py
Added migration downgrade test.
Migration Results
Postgres
```bash $ DATABASE_URL=postgresql+psycopg://apluser:apluserpass@localhost:5432/apldb poetry run ./run_migration.sh init INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> a80595c53d52, 026_v22.3 INFO [alembic.runtime.migration] Running upgrade a80595c53d52 -> e8d970fdd886, 034_v22.6 INFO [alembic.runtime.migration] Running upgrade e8d970fdd886 -> 55dee53de2ca, 041_v22.9 INFO [alembic.runtime.migration] Running upgrade 55dee53de2ca -> 446f913d1f41, 047_v22.12 INFO [alembic.runtime.migration] Running upgrade 446f913d1f41 -> 1055cb068506, 054_v23.3 INFO [alembic.runtime.migration] Running upgrade 1055cb068506 -> ca8ff8c0c01d, v23.6_feature/alembic INFO [alembic.runtime.migration] Running upgrade ca8ff8c0c01d -> 40ee030e9302, v23_6_feature_1377 $ DATABASE_URL=postgresql+psycopg://apluser:apluserpass@localhost:5432/apldb poetry run ./run_migration.sh downgrade INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running downgrade 40ee030e9302 -> ca8ff8c0c01d, v23_6_feature_1377 INFO [alembic.runtime.migration] Running downgrade ca8ff8c0c01d -> 1055cb068506, v23.6_feature/alembic INFO [alembic.runtime.migration] Running downgrade 1055cb068506 -> 446f913d1f41, 054_v23.3 INFO [alembic.runtime.migration] Running downgrade 446f913d1f41 -> 55dee53de2ca, 047_v22.12 INFO [alembic.runtime.migration] Running downgrade 55dee53de2ca -> e8d970fdd886, 041_v22.9 INFO [alembic.runtime.migration] Running downgrade e8d970fdd886 -> a80595c53d52, 034_v22.6 INFO [alembic.runtime.migration] Running downgrade a80595c53d52 -> , 026_v22.3 $ DATABASE_URL=postgresql+psycopg://apluser:apluserpass@localhost:5432/apldb poetry run ./run_migration.sh upgrade ./run_migration.sh: line 20: /Users/y-otosu/.bash_profile: No such file or directory ./run_migration.sh: line 21: cd: /app/ibet-Wallet-API: No such file or directory INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> a80595c53d52, 026_v22.3 INFO [alembic.runtime.migration] Running upgrade a80595c53d52 -> e8d970fdd886, 034_v22.6 INFO [alembic.runtime.migration] Running upgrade e8d970fdd886 -> 55dee53de2ca, 041_v22.9 INFO [alembic.runtime.migration] Running upgrade 55dee53de2ca -> 446f913d1f41, 047_v22.12 INFO [alembic.runtime.migration] Running upgrade 446f913d1f41 -> 1055cb068506, 054_v23.3 INFO [alembic.runtime.migration] Running upgrade 1055cb068506 -> ca8ff8c0c01d, v23.6_feature/alembic INFO [alembic.runtime.migration] Running upgrade ca8ff8c0c01d -> 40ee030e9302, v23_6_feature_1377 ```MySQL
```bash $ DATABASE_URL=mysql+pymysql://apluser:apluserpass@localhost:3306/apldb poetry run ./run_migration.sh init INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> a80595c53d52, 026_v22.3 INFO [alembic.runtime.migration] Running upgrade a80595c53d52 -> e8d970fdd886, 034_v22.6 INFO [alembic.runtime.migration] Running upgrade e8d970fdd886 -> 55dee53de2ca, 041_v22.9 INFO [alembic.runtime.migration] Running upgrade 55dee53de2ca -> 446f913d1f41, 047_v22.12 INFO [alembic.runtime.migration] Running upgrade 446f913d1f41 -> 1055cb068506, 054_v23.3 INFO [alembic.runtime.migration] Running upgrade 1055cb068506 -> ca8ff8c0c01d, v23.6_feature/alembic INFO [alembic.runtime.migration] Running upgrade ca8ff8c0c01d -> 40ee030e9302, v23_6_feature_1377 $ DATABASE_URL=mysql+pymysql://apluser:apluserpass@localhost:3306/apldb poetry run ./run_migration.sh downgrade INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running downgrade 40ee030e9302 -> ca8ff8c0c01d, v23_6_feature_1377 INFO [alembic.runtime.migration] Running downgrade ca8ff8c0c01d -> 1055cb068506, v23.6_feature/alembic INFO [alembic.runtime.migration] Running downgrade 1055cb068506 -> 446f913d1f41, 054_v23.3 INFO [alembic.runtime.migration] Running downgrade 446f913d1f41 -> 55dee53de2ca, 047_v22.12 INFO [alembic.runtime.migration] Running downgrade 55dee53de2ca -> e8d970fdd886, 041_v22.9 INFO [alembic.runtime.migration] Running downgrade e8d970fdd886 -> a80595c53d52, 034_v22.6 INFO [alembic.runtime.migration] Running downgrade a80595c53d52 -> , 026_v22.3 $ DATABASE_URL=mysql+pymysql://apluser:apluserpass@localhost:3306/apldb poetry run ./run_migration.sh upgrade INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> a80595c53d52, 026_v22.3 INFO [alembic.runtime.migration] Running upgrade a80595c53d52 -> e8d970fdd886, 034_v22.6 INFO [alembic.runtime.migration] Running upgrade e8d970fdd886 -> 55dee53de2ca, 041_v22.9 INFO [alembic.runtime.migration] Running upgrade 55dee53de2ca -> 446f913d1f41, 047_v22.12 INFO [alembic.runtime.migration] Running upgrade 446f913d1f41 -> 1055cb068506, 054_v23.3 INFO [alembic.runtime.migration] Running upgrade 1055cb068506 -> ca8ff8c0c01d, v23.6_feature/alembic INFO [alembic.runtime.migration] Running upgrade ca8ff8c0c01d -> 40ee030e9302, v23_6_feature_1377 ```