-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* **New:**
Repository
instances now have a code
attribute whi…
…ch is used for generating the environment variables where in previous versions the ``id`` attribute has been used which caused difficulties in transferring the data to a different installation of Stalker. Also to make the system backwards compatible, Stalker will still set the old ``id`` based environment variables. But when asked for an environment variable it will return the ``code`` based one. The ``code`` argument as usual has to be initialized on ``Repository`` instance creation. That's why this version is slightly backwards incompatible and needs the database to be updated with Alembic (with the command ``alembic update head``).
- Loading branch information
Showing
39 changed files
with
367 additions
and
86 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
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
42 changes: 42 additions & 0 deletions
42
alembic/versions/bf67e6a234b4_added_revision_code_attribute.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,42 @@ | ||
"""Added Revision.code attribute | ||
Revision ID: bf67e6a234b4 | ||
Revises: ed0167fff399 | ||
Create Date: 2020-01-01 09:50:19.086342 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'bf67e6a234b4' | ||
down_revision = 'ed0167fff399' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
|
||
|
||
def upgrade(): | ||
# add the column | ||
logger.info("creating code column in Repositories table") | ||
op.add_column( | ||
'Repositories', | ||
sa.Column('code', sa.String(length=256), nullable=True) | ||
) | ||
|
||
# copy the name as code | ||
logger.info("filling data to the code column in Repositories table from Repositories.name column") | ||
op.execute("""UPDATE "Repositories" | ||
SET code = ( | ||
SELECT REGEXP_REPLACE(name, '\s+', '') from "SimpleEntities" where id="Repositories".id | ||
) | ||
""") | ||
logger.info("set code column to not nullable") | ||
op.alter_column('Repositories', 'code', nullable=False) | ||
|
||
|
||
def downgrade(): | ||
logger.info("removing code column from Repositories table") | ||
op.drop_column('Repositories', 'code') |
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
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
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
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
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
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
Oops, something went wrong.