-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Database creation simpler command + docs
Database can be created by command calling standard SQLALchemy create_all() procedure and it's now documented as well as tip for use migrations.
- Loading branch information
1 parent
a6718f2
commit 10970be
Showing
5 changed files
with
40 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Database | ||
======== | ||
|
||
In order to create and maintain the database, you can use migrations | ||
by `Flask-Migrate`_: | ||
|
||
:: | ||
|
||
$ repocribro db --help | ||
|
||
|
||
Or you can use standard `SQLAlchemy procedure`_ ``db.create_all()``via: | ||
:: | ||
$ repocribro create-db | ||
Both will try to create tables into database specified in the | ||
:doc:`config`. | ||
.. _Flask-Migrate: https://flask-migrate.readthedocs.io/en/latest/ | ||
.. _SQLAlchemy procedure: http://docs.sqlalchemy.org/en/latest/core/metadata.html?highlight=create_all#sqlalchemy.schema.MetaData.create_all |
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 |
---|---|---|
|
@@ -5,5 +5,6 @@ Installation | |
:maxdepth: 2 | ||
|
||
install | ||
database | ||
config | ||
requirements |
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,3 +1,4 @@ | ||
from .db_create import DbCreateCommand | ||
from .repocheck import RepocheckCommand | ||
|
||
__all__ = ['RepocheckCommand'] | ||
__all__ = ['DbCreateCommand', 'RepocheckCommand'] |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from flask_script import Command | ||
|
||
|
||
class DbCreateCommand(Command): | ||
"""Perform basic create all tables""" | ||
|
||
# TODO: think about clear, drop_all, dump, .. | ||
def run(self): | ||
from ..database import db | ||
print('Performing db.create_all()') | ||
db.create_all() | ||
print('Database has been created') |
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