タイトル : 血圧降下剤の処方数量 テーブル作成
更新日 : 2024-03-16
カテゴリ : プログラミング
テーブル作成
設計した内容でSQLAlchemyのモデルファイルを作成します
alembic の --autogenerate を使ってテーブルを作成します
(alembicの設定については別途まとめた方が良さそうだな)
$ alembic revision --autogenerate -m "create tables"
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.autogenerate.compare] Detected added table 'iy_category'
INFO [alembic.autogenerate.compare] Detected added table 'iy_code'
INFO [alembic.autogenerate.compare] Detected added table 'iy_quantity'
Generating /home/prost/work/MyStudyApp/BPress/app/alembic/versions/be29b0adb347_create_tables.py ... done
$
$ alembic upgrade head
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> be29b0adb347, create tables
$
ちゃんとテーブルが作成出来ているか、psqlコマンドで確認
root@734c09b71f29:/# psql -U bpress bpress
psql (16.1 (Debian 16.1-1.pgdg120+1))
Type "help" for help.
bpress=# \d
List of relations
Schema | Name | Type | Owner
--------+--------------------+----------+--------
public | alembic_version | table | bpress
public | iy_category | table | bpress
public | iy_category_id_seq | sequence | bpress
public | iy_code | table | bpress
public | iy_code_id_seq | sequence | bpress
public | iy_quantity | table | bpress
public | iy_quantity_id_seq | sequence | bpress
(7 rows)
bpress=#