-
Notifications
You must be signed in to change notification settings - Fork 955
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate existing data and switch to using Release.is_prerelease
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
warehouse/migrations/versions/4490777c984f_migrate_existing_data_for_release_is_.py
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,52 @@ | ||
# 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. | ||
""" | ||
Migrate Existing Data for Release.is_prerelease | ||
Revision ID: 4490777c984f | ||
Revises: b0dbcd2f5c77 | ||
Create Date: 2022-06-27 17:49:09.835384 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
revision = "4490777c984f" | ||
down_revision = "b0dbcd2f5c77" | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
""" | ||
UPDATE releases | ||
SET is_prerelease = pep440_is_prerelease(version) | ||
WHERE is_prerelease IS NULL | ||
""" | ||
) | ||
op.alter_column( | ||
"releases", | ||
"is_prerelease", | ||
existing_type=sa.BOOLEAN(), | ||
server_default=sa.text("false"), | ||
nullable=False, | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.alter_column( | ||
"releases", | ||
"is_prerelease", | ||
existing_type=sa.BOOLEAN(), | ||
server_default=None, | ||
nullable=True, | ||
) |
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