diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-11-11 12:27:01 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-11-11 12:27:01 +0000 |
commit | 027b9cc9e1564b671cf536e962be421c13b96dcf (patch) | |
tree | ed103065c7358f388d96661b40768b1ce5812fa9 | |
parent | c43b877741e0f7bce686ac1e565a13b5b6620bb9 (diff) |
added Make rules to populate postgres testdb
-rw-r--r-- | Makefile | 25 | ||||
-rw-r--r-- | config/settings/gcloud_settings.py | 14 |
2 files changed, 37 insertions, 2 deletions
@@ -1,5 +1,30 @@ +SUPERUSER_NAME=mlemon +SUPERUSER_PASSWD=lemonlemon +SUPERUSER_EMAIL=bob@bob.com +DATABASE_NAME=ctrack +DATABASE_USER=postres + test: pytest --tb=short -v test-fast: pytest -k "not test_functional" --tb=short + +initialisedb: populate + python manage.py createsuperuser + +populate: migrate + @echo "Populating new database with test data." + python manage.py populate_db + +migrate: createdb + @echo "Migrating." + python manage.py migrate + +createdb: dropdb + @echo "Creating a new database." + createdb $(DATABASE_NAME) -O postgres + +dropdb: + @echo "Dropping any existing ctrack database." + psql -U postgres -c "DROP DATABASE IF EXISTS $(DATABASE_NAME);" diff --git a/config/settings/gcloud_settings.py b/config/settings/gcloud_settings.py index c0c79a5..8eb6ac2 100644 --- a/config/settings/gcloud_settings.py +++ b/config/settings/gcloud_settings.py @@ -236,10 +236,20 @@ else: # $ cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 # # See https://cloud.google.com/sql/docs/mysql-connect-proxy + # DATABASES = { + # 'default': { + # 'ENGINE': 'django.db.backends.sqlite3', + # 'NAME': os.path.join(ROOT_DIR, 'ctrack.db'), + # } + # } DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(ROOT_DIR, 'ctrack.db'), + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'ctrack', + 'USER': 'postgres', + 'PASSWORD': 'postgres', + 'HOST': '127.0.0.1', + 'PORT': '5432', } } # [END db_setup] |