mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
feat: add ability to skip migrations
This feature can be used in order to handle conflicting migrations
This commit is contained in:
parent
2c21ae26c3
commit
d1132b49fc
@ -34,8 +34,9 @@ It will check current settings on common errors and compare configuration with k
|
|||||||
|
|
||||||
Base configuration settings.
|
Base configuration settings.
|
||||||
|
|
||||||
* ``include`` - path to directory with configuration files overrides, string, required.
|
* ``apply_migrations`` - perform migrations on application start, boolean, optional, default ``yes``. Useful if you are using git version. Note, however, that this option must be changed only if you know what to do and going to handle migrations automatically.
|
||||||
* ``database`` - path to SQLite database, string, required.
|
* ``database`` - path to SQLite database, string, required.
|
||||||
|
* ``include`` - path to directory with configuration files overrides, string, required.
|
||||||
* ``logging`` - path to logging configuration, string, required. Check ``logging.ini`` for reference.
|
* ``logging`` - path to logging configuration, string, required. Check ``logging.ini`` for reference.
|
||||||
* ``suppress_http_log_errors`` - suppress http log errors, boolean, optional, default ``no``. If set to ``yes``, any http log errors (e.g. if web server is not available, but http logging is enabled) will be suppressed.
|
* ``suppress_http_log_errors`` - suppress http log errors, boolean, optional, default ``no``. If set to ``yes``, any http log errors (e.g. if web server is not available, but http logging is enabled) will be suppressed.
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[settings]
|
[settings]
|
||||||
include = ahriman.ini.d
|
include = ahriman.ini.d
|
||||||
logging = ahriman.ini.d/logging.ini
|
logging = ahriman.ini.d/logging.ini
|
||||||
|
apply_migrations = yes
|
||||||
database = /var/lib/ahriman/ahriman.db
|
database = /var/lib/ahriman/ahriman.db
|
||||||
suppress_http_log_errors = yes
|
suppress_http_log_errors = yes
|
||||||
|
|
||||||
|
@ -30,17 +30,21 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
|
|||||||
"settings": {
|
"settings": {
|
||||||
"type": "dict",
|
"type": "dict",
|
||||||
"schema": {
|
"schema": {
|
||||||
"include": {
|
"apply_migrations": {
|
||||||
"type": "path",
|
"type": "boolean",
|
||||||
"coerce": "absolute_path",
|
"coerce": "boolean",
|
||||||
"required": True,
|
|
||||||
"path_exists": True,
|
|
||||||
},
|
},
|
||||||
"database": {
|
"database": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"coerce": "absolute_path",
|
"coerce": "absolute_path",
|
||||||
"required": True,
|
"required": True,
|
||||||
},
|
},
|
||||||
|
"include": {
|
||||||
|
"type": "path",
|
||||||
|
"coerce": "absolute_path",
|
||||||
|
"required": True,
|
||||||
|
"path_exists": True,
|
||||||
|
},
|
||||||
"logging": {
|
"logging": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"coerce": "absolute_path",
|
"coerce": "absolute_path",
|
||||||
|
@ -87,5 +87,6 @@ class SQLite(AuthOperations, BuildOperations, LogsOperations, PackageOperations,
|
|||||||
|
|
||||||
paths = configuration.repository_paths
|
paths = configuration.repository_paths
|
||||||
|
|
||||||
self.with_connection(lambda connection: Migrations.migrate(connection, configuration))
|
if configuration.getboolean("settings", "apply_migrations", fallback=True):
|
||||||
|
self.with_connection(lambda connection: Migrations.migrate(connection, configuration))
|
||||||
paths.chown(self.path)
|
paths.chown(self.path)
|
||||||
|
@ -22,3 +22,14 @@ def test_init(database: SQLite, configuration: Configuration, mocker: MockerFixt
|
|||||||
migrate_schema_mock = mocker.patch("ahriman.core.database.migrations.Migrations.migrate")
|
migrate_schema_mock = mocker.patch("ahriman.core.database.migrations.Migrations.migrate")
|
||||||
database.init(configuration)
|
database.init(configuration)
|
||||||
migrate_schema_mock.assert_called_once_with(pytest.helpers.anyvar(int), configuration)
|
migrate_schema_mock.assert_called_once_with(pytest.helpers.anyvar(int), configuration)
|
||||||
|
|
||||||
|
|
||||||
|
def test_init_skip_migration(database: SQLite, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must skip migrations if option is set
|
||||||
|
"""
|
||||||
|
configuration.set_option("settings", "apply_migrations", "no")
|
||||||
|
migrate_schema_mock = mocker.patch("ahriman.core.database.migrations.Migrations.migrate")
|
||||||
|
|
||||||
|
database.init(configuration)
|
||||||
|
migrate_schema_mock.assert_not_called()
|
||||||
|
Loading…
Reference in New Issue
Block a user