Skip to content

Commit 683c832

Browse files
authored
Ensure that migrate writes sqlite dbs into the cwd. (#13)
Previously it would write them into the sandbox if created by ./pants run. Also gitignores the sqlite journal file, so that pants will ignore it too, preventing spurious file watcher events as the migrations are applied.
1 parent ef88bc9 commit 683c832

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ __pycache__/
2121

2222
# Local databases.
2323
*.sqlite3
24+
*.sqlite3-journal
2425

2526
# MacOS attribute files
2627
.DS_Store

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,5 @@ To run migrations, it's best to use the admin service's manage.py, as it has acc
126126
all apps:
127127

128128
```
129-
./pants helloworld/service/admin/manage.py -- migrate --database=users --database=greetings
129+
./pants run helloworld/service/admin/manage.py -- migrate --database=users --database=greetings
130130
```

helloworld/settings_base.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
HELLOWORLD_MODE = os.environ.get("HELLOWORLD_MODE", "DEV")
1212

13-
# Construct paths inside the project like this: os.path.join(BASE_DIR, ...)
14-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15-
1613
SECRET_KEY = "DEV_SECURITY_KEY"
1714

1815
DEBUG = True
@@ -55,7 +52,7 @@ def set_up_database(db_name: str):
5552
# TODO: Consult HELLOWORLD_MODE to distinguish dev/staging/prod dbs.
5653
DATABASES[db_name] = {
5754
"ENGINE": "django.db.backends.sqlite3",
58-
"NAME": os.path.join(BASE_DIR, f"{db_name}.sqlite3"),
55+
"NAME": f"{db_name}.sqlite3",
5956
}
6057

6158

0 commit comments

Comments
 (0)