summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Kekane <akekane@redhat.com>2022-10-18 12:51:41 +0000
committerAbhishek Kekane <akekane@redhat.com>2023-01-18 04:57:34 +0000
commit9786936915f7745c2b9109eb475962f41a0df67b (patch)
tree52dbcfc6a5da4fd3f66e63fb0afebc9fde9daf68
parentd07187f7107b02f42cfa335a22763cbb1c085587 (diff)
downloadglance-9786936915f7745c2b9109eb475962f41a0df67b.tar.gz
Update migration constant
Update the data migration current release to '2023_1'. Added empty migration scripts to rule out regression scenarios as well. Change-Id: Ic97825dd9c38ec1c759e5ca610a19c93fe4ca6a6
-rw-r--r--glance/db/migration.py2
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/data_migrations/2023_1_migrate01_empty.py26
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/data_migrations/xena_migrate01_empty.py26
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/data_migrations/yoga_migrate01_empty.py26
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/data_migrations/zed_migrate01_empty.py26
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/2023_1_contract01_empty.py25
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/2023_1_expand01_empty.py30
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/xena_contract01_empty.py25
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/xena_expand01_empty.py30
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/yoga_contract01_empty.py25
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/yoga_expand01_empty.py30
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/zed_contract01_empty.py25
-rw-r--r--glance/db/sqlalchemy/alembic_migrations/versions/zed_expand01_empty.py30
-rw-r--r--glance/tests/functional/db/test_migrations.py53
14 files changed, 363 insertions, 16 deletions
diff --git a/glance/db/migration.py b/glance/db/migration.py
index f6fdd8d08..1977de469 100644
--- a/glance/db/migration.py
+++ b/glance/db/migration.py
@@ -29,5 +29,5 @@ db_options.set_defaults(cfg.CONF)
# Migration-related constants
EXPAND_BRANCH = 'expand'
CONTRACT_BRANCH = 'contract'
-CURRENT_RELEASE = 'zed'
+CURRENT_RELEASE = '2023_1'
ALEMBIC_INIT_VERSION = 'liberty'
diff --git a/glance/db/sqlalchemy/alembic_migrations/data_migrations/2023_1_migrate01_empty.py b/glance/db/sqlalchemy/alembic_migrations/data_migrations/2023_1_migrate01_empty.py
new file mode 100644
index 000000000..893d66db9
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/data_migrations/2023_1_migrate01_empty.py
@@ -0,0 +1,26 @@
+# Copyright (C) 2021 RedHat Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+def has_migrations(engine):
+ """Returns true if at least one data row can be migrated."""
+
+ return False
+
+
+def migrate(engine):
+ """Return the number of rows migrated."""
+
+ return 0
diff --git a/glance/db/sqlalchemy/alembic_migrations/data_migrations/xena_migrate01_empty.py b/glance/db/sqlalchemy/alembic_migrations/data_migrations/xena_migrate01_empty.py
new file mode 100644
index 000000000..893d66db9
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/data_migrations/xena_migrate01_empty.py
@@ -0,0 +1,26 @@
+# Copyright (C) 2021 RedHat Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+def has_migrations(engine):
+ """Returns true if at least one data row can be migrated."""
+
+ return False
+
+
+def migrate(engine):
+ """Return the number of rows migrated."""
+
+ return 0
diff --git a/glance/db/sqlalchemy/alembic_migrations/data_migrations/yoga_migrate01_empty.py b/glance/db/sqlalchemy/alembic_migrations/data_migrations/yoga_migrate01_empty.py
new file mode 100644
index 000000000..893d66db9
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/data_migrations/yoga_migrate01_empty.py
@@ -0,0 +1,26 @@
+# Copyright (C) 2021 RedHat Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+def has_migrations(engine):
+ """Returns true if at least one data row can be migrated."""
+
+ return False
+
+
+def migrate(engine):
+ """Return the number of rows migrated."""
+
+ return 0
diff --git a/glance/db/sqlalchemy/alembic_migrations/data_migrations/zed_migrate01_empty.py b/glance/db/sqlalchemy/alembic_migrations/data_migrations/zed_migrate01_empty.py
new file mode 100644
index 000000000..893d66db9
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/data_migrations/zed_migrate01_empty.py
@@ -0,0 +1,26 @@
+# Copyright (C) 2021 RedHat Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+def has_migrations(engine):
+ """Returns true if at least one data row can be migrated."""
+
+ return False
+
+
+def migrate(engine):
+ """Return the number of rows migrated."""
+
+ return 0
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/2023_1_contract01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/2023_1_contract01_empty.py
new file mode 100644
index 000000000..b9afc5e76
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/2023_1_contract01_empty.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2020 RedHat Inc
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+# revision identifiers, used by Alembic.
+revision = '2023_1_contract01'
+down_revision = 'zed_contract01'
+branch_labels = None
+depends_on = '2023_1_expand01'
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/2023_1_expand01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/2023_1_expand01_empty.py
new file mode 100644
index 000000000..334766c2f
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/2023_1_expand01_empty.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 RedHat Inc
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""empty expand for symmetry with 2023_1_expand01
+
+Revision ID: ussuri_expand01
+Revises: train_expand01
+Create Date: 2020-01-03 11:55:16.657499
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '2023_1_expand01'
+down_revision = 'zed_expand01'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/xena_contract01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/xena_contract01_empty.py
new file mode 100644
index 000000000..ecbb75cfd
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/xena_contract01_empty.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2020 RedHat Inc
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+# revision identifiers, used by Alembic.
+revision = 'xena_contract01'
+down_revision = 'wallaby_contract01'
+branch_labels = None
+depends_on = 'xena_expand01'
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/xena_expand01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/xena_expand01_empty.py
new file mode 100644
index 000000000..42306928d
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/xena_expand01_empty.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 RedHat Inc
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""empty expand for symmetry with 2023_1_expand01
+
+Revision ID: ussuri_expand01
+Revises: train_expand01
+Create Date: 2020-01-03 11:55:16.657499
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'xena_expand01'
+down_revision = 'wallaby_expand01'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/yoga_contract01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/yoga_contract01_empty.py
new file mode 100644
index 000000000..082be9994
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/yoga_contract01_empty.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2020 RedHat Inc
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+# revision identifiers, used by Alembic.
+revision = 'yoga_contract01'
+down_revision = 'xena_contract01'
+branch_labels = None
+depends_on = 'yoga_expand01'
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/yoga_expand01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/yoga_expand01_empty.py
new file mode 100644
index 000000000..f984a2fa5
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/yoga_expand01_empty.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 RedHat Inc
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""empty expand for symmetry with 2023_1_expand01
+
+Revision ID: ussuri_expand01
+Revises: train_expand01
+Create Date: 2020-01-03 11:55:16.657499
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'yoga_expand01'
+down_revision = 'xena_expand01'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/zed_contract01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/zed_contract01_empty.py
new file mode 100644
index 000000000..32d36ddfb
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/zed_contract01_empty.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2020 RedHat Inc
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+# revision identifiers, used by Alembic.
+revision = 'zed_contract01'
+down_revision = 'yoga_contract01'
+branch_labels = None
+depends_on = 'zed_expand01'
+
+
+def upgrade():
+ pass
diff --git a/glance/db/sqlalchemy/alembic_migrations/versions/zed_expand01_empty.py b/glance/db/sqlalchemy/alembic_migrations/versions/zed_expand01_empty.py
new file mode 100644
index 000000000..14e6e081d
--- /dev/null
+++ b/glance/db/sqlalchemy/alembic_migrations/versions/zed_expand01_empty.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 RedHat Inc
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""empty expand for symmetry with 2023_1_expand01
+
+Revision ID: ussuri_expand01
+Revises: train_expand01
+Create Date: 2020-01-03 11:55:16.657499
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'zed_expand01'
+down_revision = 'yoga_expand01'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ pass
diff --git a/glance/tests/functional/db/test_migrations.py b/glance/tests/functional/db/test_migrations.py
index 0f7f0b4df..150af726d 100644
--- a/glance/tests/functional/db/test_migrations.py
+++ b/glance/tests/functional/db/test_migrations.py
@@ -63,21 +63,44 @@ class TestVersions(test_utils.BaseTestCase):
for prefix in exception_releases]):
continue
- # File format should be release_phaseNN_description.py
- try:
- _rest = '' # noqa
- release, phasever, _rest = version_file.split('_', 2)
- except ValueError:
- release = phasever = ''
- phase = ''.join(x for x in phasever if x.isalpha())
- # Grab the non-numeric part of phaseNN
- if phase not in required_phases:
- # Help make sure that going forward developers stick to the
- # consistent format.
- self.fail('Migration files should be in the form of: '
- 'release_phaseNN_some_description.py '
- '(while processing %r)' % version_file)
- releases[release].add(phase)
+ # For legacy database scripts does not starts with
+ # YYYY i.e. pre Antelope
+ if not version_file.split('_', 2)[0].isnumeric():
+ # File format should be release_phaseNN_description.py
+ try:
+ _rest = '' # noqa
+ release, phasever, _rest = version_file.split('_', 2)
+ except ValueError:
+ release = phasever = ''
+ phase = ''.join(x for x in phasever if x.isalpha())
+ # Grab the non-numeric part of phaseNN
+ if phase not in required_phases:
+ # Help make sure that going forward developers stick to the
+ # consistent format.
+ self.fail('Migration files should be in the form of: '
+ 'release_phaseNN_some_description.py '
+ '(while processing %r)' % version_file)
+ releases[release].add(phase)
+ else:
+ # For new database scripts i.e. Antelope onwards
+ # File format should be
+ # releaseYear_releaseN_phaseNN_description.py
+ # For example 2023_1_expand01_empty.py
+ try:
+ _rest = '' # noqa
+ release_y, release_n, phasever, _rest = version_file.split(
+ '_', 3)
+ except ValueError:
+ release_y = phasever = ''
+ phase = ''.join(x for x in phasever if x.isalpha())
+ # Grab the non-numeric part of phaseNN
+ if phase not in required_phases:
+ # Help make sure that going forward developers stick to the
+ # consistent format.
+ self.fail('Migration files should be in the form of: '
+ 'releaseYear_releaseN_phaseNN_description.py '
+ '(while processing %r)' % version_file)
+ releases[release_y].add(phase)
for release, phases in releases.items():
missing = required_phases - phases