Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csentry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Harrisson
csentry
Commits
d895cd47
Commit
d895cd47
authored
7 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Remove sqlalchemy create_all() call
Let alembic handle the database creation and migration
parent
e5655355
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+7
-3
7 additions, 3 deletions
Makefile
README.rst
+3
-2
3 additions, 2 deletions
README.rst
app/commands.py
+2
-4
2 additions, 4 deletions
app/commands.py
with
12 additions
and
9 deletions
Makefile
+
7
−
3
View file @
d895cd47
.PHONY
:
help build tag push refresh release db initdb test db_image test_image
.PHONY
:
help build tag push refresh release db init
_db upgrade_
db test db_image test_image
OWNER
:=
registry.esss.lu.se/ics-infrastructure
OWNER
:=
registry.esss.lu.se/ics-infrastructure
GIT_TAG
:=
$(
shell git describe
--always
)
GIT_TAG
:=
$(
shell git describe
--always
)
...
@@ -40,8 +40,12 @@ release: ## build, tag, and push all stacks
...
@@ -40,8 +40,12 @@ release: ## build, tag, and push all stacks
db
:
##
start postgres and redis for development
db
:
##
start postgres and redis for development
docker-compose up
-d
postgres redis
docker-compose up
-d
postgres redis
initdb
:
##
initialize the dev database
init_db
:
##
initialize the dev database
docker-compose run
--rm
web flask initdb
docker-compose run
--rm
web flask db upgrade
head
docker-compose run
--rm
web flask create_defaults
upgrade_db
:
##
upgrade the dev database
docker-compose run
--rm
web flask db upgrade
head
test
:
##
run the tests (on current directory)
test
:
##
run the tests (on current directory)
docker-compose run
--rm
web pytest
--cov
=
app
-v
docker-compose run
--rm
web pytest
--cov
=
app
-v
...
...
This diff is collapsed.
Click to expand it.
README.rst
+
3
−
2
View file @
d895cd47
...
@@ -19,9 +19,10 @@ You can use docker for development:
...
@@ -19,9 +19,10 @@ You can use docker for development:
or
or
$ make db
$ make db
# Initialize the database
# Initialize the database
$ docker-compose run --rm web flask initdb
$ docker-compose run --rm web flask db upgrade head
$ docker-compose run --rm web flask create_defaults
or
or
$ make initdb
$ make init
_
db
3. Start the application::
3. Start the application::
...
...
This diff is collapsed.
Click to expand it.
app/commands.py
+
2
−
4
View file @
d895cd47
...
@@ -63,10 +63,8 @@ def sync_users():
...
@@ -63,10 +63,8 @@ def sync_users():
def
register_cli
(
app
):
def
register_cli
(
app
):
@app.cli.command
()
@app.cli.command
()
def
initdb
():
def
create_defaults
():
"""
Create the database tables and initialize them with default values
"""
"""
Create the database default values
"""
db
.
engine
.
execute
(
'
CREATE EXTENSION IF NOT EXISTS citext
'
)
db
.
create_all
()
for
instance
in
defaults
:
for
instance
in
defaults
:
db
.
session
.
add
(
instance
)
db
.
session
.
add
(
instance
)
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment