-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmigrate.py
More file actions
executable file
·34 lines (24 loc) · 848 Bytes
/
migrate.py
File metadata and controls
executable file
·34 lines (24 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import sys
# Make sure the app is (at least temporarily) on the import path.
APP_DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(APP_DIR, "src/"))
SETTINGS_DICT = {
"INSTALLED_APPS": [
"django.contrib.auth",
"django.contrib.contenttypes",
"subscriptions.apps.SubscriptionsConfig",
],
"DATABASES": {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}},
}
def migrate(name):
from django.conf import settings
settings.configure(**SETTINGS_DICT)
import django
django.setup()
from django.core import management
management.call_command("makemigrations", "subscriptions", name=name)
if __name__ == "__main__":
args = sys.argv[1:]
assert len(args) == 1, "Must supply the name of the migration"
migrate(args[0])