@@ -37,22 +37,68 @@ $ psql -U postgres -c "create user dpr_user password 'secret' createdb;"
37
37
$ psql -U postgres -c "create database dpr_db owner=dpr_user;"
38
38
39
39
# create tables
40
- python manager.py db upgrade
40
+ $ python manager.py createdb
41
+ $ python manager.py populate
41
42
```
42
43
44
+ While development, if you make changes to database structure, Eg: added new table,
45
+ renamed column etc... You will have to ** drop** all the tables and recreate them
46
+
47
+ ```
48
+ $ python manager.py dropdb
49
+ $ python manager.py createdb
50
+ $ python manager.py populate
51
+ ```
52
+
53
+ Note: Be careful! Doing so ** all** of you data will be erased. ** Never, ever** run
54
+ ` python manager.py dropdb ` on production database like RDS or any other, unless you
55
+ are super confident what are you doing!
56
+
43
57
### Environment Configuration
44
58
45
59
Rename the env.template file to .env file and edit it.
46
60
47
- TODO: guidance about this including how to use the DB you created in the
48
- previous step.
61
+ ```
62
+ JWT_SEED=<<Super Secret Key For Flask Sessions>>
63
+ SQLALCHEMY_DATABASE_URI=<<Postgres Database URI>>*
64
+ S3_BUCKET_NAME=<<AWS S3 Bucket Name For Data Storage>>
65
+ AWS_ACCESS_KEY_ID= <<AWS Access Key>>
66
+ AWS_SECRET_ACCESS_KEY= <<AWS Secret Access Key>>
67
+ AWS_REGION= <<AWS Region >>
68
+ GITHUB_CLIENT_ID= <<Github Client ID>>
69
+ GITHUB_CLIENT_SECRET= <<Github Client Secret>>
70
+
71
+ # For Deploy
72
+ PROJECT= <<Project Name>>
73
+ DOMAIN_BASE= <<Domain Base. Eg: example.com>>
74
+ STAGE=<<Project Stage. Eg: dev>>
75
+ DOMAIN=<<Full Domain. Eg: dev.example.com>>
76
+ DPR_API_GIT=<<Git URL For Repo>>
77
+ ```
78
+
79
+ For local development you can leave empty all variables except following ones:
80
+
81
+ - SQLALCHEMY_DATABASE_URI
82
+ - JWT_SEED
83
+ - AWS_REGION
84
+ - GITHUB_CLIENT_ID
85
+ - GITHUB_CLIENT_SECRET
86
+
87
+ You can use any string you like, Eg: "development", for all of them, except ` SQLALCHEMY_DATABASE_URI `
88
+
89
+ SQLALCHEMY_DATABASE_URI should follow the general form for a postgresq connection URI:
90
+ ` postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...] `
91
+
92
+ If you created postgres database by following our instructions above, it should look like this:
93
+
94
+ ` SQLALCHEMY_DATABASE_URI=postgres://dpr_user:secret@localhost/dpr_db `
49
95
50
96
### Running locally
51
97
52
98
You can now run the app locally! To do, run:
53
99
54
100
```
55
- python dpr.py
101
+ $ python dpr.py
56
102
```
57
103
58
104
## Testing
@@ -66,21 +112,15 @@ $ export FLASK_CONFIGURATION=test
66
112
This ensures that tests are not dependent on any env variable. By default it is dependent on
67
113
local postgresql instance.
68
114
69
- TODO: explain how to set up this postgresql instance.
70
-
71
- We use pytest for testing. All tests are in tests directory. To run the tests do:
115
+ You would want to create separate database for tests, for not loosing all the data
116
+ from development database, you are working with.
72
117
73
118
```
74
- pytest tests
119
+ $ psql -U postgres -c "create database dpr_test_db owner=dpr_user;"
75
120
```
76
121
77
- ## Continuous deployment process
122
+ We use pytest for testing. All tests are in tests directory. To run the tests do:
78
123
79
124
```
80
- git pull origin master
81
- git checkout deploy
82
- # if you do not yet have the deploy branch
83
- git checkout -b deploy
84
- git merge master
85
- git push origin deploy
125
+ $ pytest tests
86
126
```
0 commit comments