-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This automated commit applies the latest updates from our cookiecutters [1] to this repo. [1]: https://github.com/hypothesis/cookiecutters
- Loading branch information
1 parent
83a6259
commit aaf797e
Showing
14 changed files
with
181 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
"""Initialize the dev environment's DB.""" | ||
#!/usr/bin/env python3 | ||
import sys | ||
"""Initialize the dev environment's DB.""" | ||
import alembic.command | ||
import alembic.config | ||
from pyramid.paster import bootstrap | ||
bootstrap("conf/development.ini") | ||
from sqlalchemy import text | ||
from sqlalchemy.exc import ProgrammingError | ||
|
||
from test_pyramid_app.db import Base, create_engine | ||
|
||
|
||
def is_stamped(engine) -> bool: | ||
"""Return True if the DB is stamped with an Alembic revision ID.""" | ||
with engine.connect() as connection: | ||
try: | ||
if connection.execute(text("select * from alembic_version")).first(): | ||
return True | ||
except ProgrammingError: | ||
pass | ||
|
||
return False | ||
|
||
|
||
def main(): | ||
with bootstrap("conf/development.ini") as env: | ||
settings = env["registry"].settings | ||
engine = create_engine(settings) | ||
|
||
if not is_stamped(engine): | ||
Base.metadata.create_all(engine) | ||
alembic.command.stamp(alembic.config.Config("conf/alembic.ini"), "head") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ newrelic | |
sqlalchemy | ||
psycopg2 | ||
alembic | ||
pyramid-tm | ||
zope.sqlalchemy | ||
celery | ||
pyramid-googleauth | ||
pyramid-jinja2 |
Oops, something went wrong.