diff options
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 | ) | ||