mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Disable Alembic support on test databases
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
e4cbe264cf
commit
81d55e70ee
2 changed files with 10 additions and 4 deletions
|
@ -36,14 +36,17 @@ def run(args):
|
||||||
# Ensure Alembic is fine before we do the real work, in order not to fail at
|
# Ensure Alembic is fine before we do the real work, in order not to fail at
|
||||||
# the last step and leave the database in an inconsistent state. The
|
# the last step and leave the database in an inconsistent state. The
|
||||||
# configuration is loaded lazily, so we query it to force its loading.
|
# configuration is loaded lazily, so we query it to force its loading.
|
||||||
alembic_config = alembic.config.Config('alembic.ini')
|
if args.use_alembic:
|
||||||
alembic_config.get_main_option('script_location')
|
alembic_config = alembic.config.Config('alembic.ini')
|
||||||
|
alembic_config.get_main_option('script_location')
|
||||||
|
|
||||||
engine = sqlalchemy.create_engine(aurweb.db.get_sqlalchemy_url(),
|
engine = sqlalchemy.create_engine(aurweb.db.get_sqlalchemy_url(),
|
||||||
echo=(args.verbose >= 1))
|
echo=(args.verbose >= 1))
|
||||||
aurweb.schema.metadata.create_all(engine)
|
aurweb.schema.metadata.create_all(engine)
|
||||||
feed_initial_data(engine.connect())
|
feed_initial_data(engine.connect())
|
||||||
alembic.command.stamp(alembic_config, 'head')
|
|
||||||
|
if args.use_alembic:
|
||||||
|
alembic.command.stamp(alembic_config, 'head')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -52,5 +55,8 @@ if __name__ == '__main__':
|
||||||
description='Initialize the aurweb database.')
|
description='Initialize the aurweb database.')
|
||||||
parser.add_argument('-v', '--verbose', action='count', default=0,
|
parser.add_argument('-v', '--verbose', action='count', default=0,
|
||||||
help='increase verbosity')
|
help='increase verbosity')
|
||||||
|
parser.add_argument('--no-alembic',
|
||||||
|
help='disable Alembic migrations support',
|
||||||
|
dest='use_alembic', action='store_false')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
run(args)
|
run(args)
|
||||||
|
|
|
@ -110,7 +110,7 @@ SSH_TTY=/dev/pts/0
|
||||||
export SSH_CLIENT SSH_CONNECTION SSH_TTY
|
export SSH_CLIENT SSH_CONNECTION SSH_TTY
|
||||||
|
|
||||||
# Initialize the test database.
|
# Initialize the test database.
|
||||||
python -m aurweb.initdb
|
python -m aurweb.initdb --no-alembic
|
||||||
|
|
||||||
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (1, 'user', '!', 'user@localhost', 'en', 1);" | sqlite3 aur.db
|
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (1, 'user', '!', 'user@localhost', 'en', 1);" | sqlite3 aur.db
|
||||||
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (2, 'tu', '!', 'tu@localhost', 'en', 2);" | sqlite3 aur.db
|
echo "INSERT INTO Users (ID, UserName, Passwd, Email, LangPreference, AccountTypeID) VALUES (2, 'tu', '!', 'tu@localhost', 'en', 2);" | sqlite3 aur.db
|
||||||
|
|
Loading…
Add table
Reference in a new issue