forked from privacyidea/privacyidea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '3757/add_node_names_to_db'
- Loading branch information
Showing
13 changed files
with
269 additions
and
108 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""v3.10: Add table nodename | ||
Revision ID: e3a64b4ca634 | ||
Revises: 5cb310101a1f | ||
Create Date: 2023-11-23 11:41:30.149153 | ||
""" | ||
from datetime import datetime | ||
from dateutil.tz import tzutc | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.exc import OperationalError, ProgrammingError | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'e3a64b4ca634' | ||
down_revision = '5cb310101a1f' | ||
|
||
|
||
def upgrade(): | ||
try: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('nodename', | ||
sa.Column('id', sa.Unicode(length=36), nullable=False), | ||
sa.Column('name', sa.Unicode(length=100), nullable=True), | ||
sa.Column('lastseen', sa.DateTime(), nullable=True, default=datetime.now(tz=tzutc())), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_index(op.f('ix_nodename_lastseen'), 'nodename', ['lastseen'], unique=False) | ||
op.create_index(op.f('ix_nodename_name'), 'nodename', ['name'], unique=False) | ||
# ### end Alembic commands ### | ||
except (OperationalError, ProgrammingError) as exx: | ||
if "already exists" in str(exx.orig).lower(): | ||
print("Ok, Table 'nodename' already exists.") | ||
else: | ||
print(exx) | ||
except Exception as exx: | ||
print("Could not add table 'nodename' to database") | ||
print(exx) | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f('ix_nodename_name'), table_name='nodename') | ||
op.drop_index(op.f('ix_nodename_lastseen'), table_name='nodename') | ||
op.drop_table('nodename') | ||
# ### end Alembic commands ### |
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.