diff options
author | clarkzjw <[email protected]> | 2023-03-10 20:29:16 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-03-10 20:29:16 -0800 |
commit | 8332a935ab85c451a7481b05b9709bcd466dbe01 (patch) | |
tree | 2ce45347f1836882a098958cb9699b9b6f6111e9 /bot/migrations | |
parent | 15ed2a825c760b3ae946d8b7a57a063f8bf393c9 (diff) | |
download | photo-8332a935ab85c451a7481b05b9709bcd466dbe01.tar.gz |
add caption and exif
Diffstat (limited to 'bot/migrations')
-rw-r--r-- | bot/migrations/0001-add_exif.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bot/migrations/0001-add_exif.py b/bot/migrations/0001-add_exif.py new file mode 100644 index 0000000..0eff797 --- /dev/null +++ b/bot/migrations/0001-add_exif.py | |||
@@ -0,0 +1,22 @@ | |||
1 | import os | ||
2 | import sys | ||
3 | from playhouse.migrate import * | ||
4 | |||
5 | |||
6 | if os.getenv("DB_DRIVER") == "psql": | ||
7 | db = PostgresqlDatabase(os.getenv("DB_NAME"), user=os.getenv("DB_USER"), password=os.getenv("DB_PASS"), | ||
8 | host=os.getenv("DB_HOST"), port=os.getenv("DB_PORT")) | ||
9 | migrator = PostgresqlMigrator(db) | ||
10 | elif os.getenv("DB_DRIVER") == "sqlite3": | ||
11 | db = SqliteDatabase("database/photos.db") | ||
12 | migrator = SqliteMigrator(db) | ||
13 | else: | ||
14 | print("No DB_DRIVER specified") | ||
15 | sys.exit(1) | ||
16 | |||
17 | model = CharField(max_length=256, default="") | ||
18 | |||
19 | # Run the migration, specifying the database table, field name and field. | ||
20 | migrate( | ||
21 | migrator.add_column('photo', 'model', model), | ||
22 | ) | ||