From 8332a935ab85c451a7481b05b9709bcd466dbe01 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Fri, 10 Mar 2023 20:29:16 -0800 Subject: add caption and exif --- bot/migrations/0001-add_exif.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bot/migrations/0001-add_exif.py (limited to 'bot/migrations') 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 @@ +import os +import sys +from playhouse.migrate import * + + +if os.getenv("DB_DRIVER") == "psql": + db = PostgresqlDatabase(os.getenv("DB_NAME"), user=os.getenv("DB_USER"), password=os.getenv("DB_PASS"), + host=os.getenv("DB_HOST"), port=os.getenv("DB_PORT")) + migrator = PostgresqlMigrator(db) +elif os.getenv("DB_DRIVER") == "sqlite3": + db = SqliteDatabase("database/photos.db") + migrator = SqliteMigrator(db) +else: + print("No DB_DRIVER specified") + sys.exit(1) + +model = CharField(max_length=256, default="") + +# Run the migration, specifying the database table, field name and field. +migrate( + migrator.add_column('photo', 'model', model), +) -- cgit v1.2.3