id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1 value | extension stringclasses 14 values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12 values | repo_extraction_date stringclasses 433 values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
23,800 | 2019-10-25_12-36_pool_on_delete_cascade.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-10-25_12-36_pool_on_delete_cascade.py | """Pool ON DELETE CASCADE
Revision ID: 6d65fd64e91c
Revises: ed69a9a6fab1
Create Date: 2019-10-25 12:36:15.863824+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6d65fd64e91c'
down_revision = 'ed69a9a6fab1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_encrypteddisk', schema=None) as batch_op:
batch_op.drop_constraint('fk_storage_encrypteddisk_encrypted_volume_id_storage_volume', type_='foreignkey')
batch_op.create_foreign_key(batch_op.f('fk_storage_encrypteddisk_encrypted_volume_id_storage_volume'), 'storage_volume', ['encrypted_volume_id'], ['id'], ondelete='CASCADE')
with op.batch_alter_table('storage_scrub', schema=None) as batch_op:
batch_op.drop_constraint('fk_storage_scrub_scrub_volume_id_storage_volume', type_='foreignkey')
batch_op.create_foreign_key(batch_op.f('fk_storage_scrub_scrub_volume_id_storage_volume'), 'storage_volume', ['scrub_volume_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_scrub', schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f('fk_storage_scrub_scrub_volume_id_storage_volume'), type_='foreignkey')
batch_op.create_foreign_key('fk_storage_scrub_scrub_volume_id_storage_volume', 'storage_volume', ['scrub_volume_id'], ['id'])
with op.batch_alter_table('storage_encrypteddisk', schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f('fk_storage_encrypteddisk_encrypted_volume_id_storage_volume'), type_='foreignkey')
batch_op.create_foreign_key('fk_storage_encrypteddisk_encrypted_volume_id_storage_volume', 'storage_volume', ['encrypted_volume_id'], ['id'])
# ### end Alembic commands ###
| 1,958 | Python | .py | 30 | 60.666667 | 181 | 0.723382 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,801 | 2019-09-20_11-01_fix_references.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-09-20_11-01_fix_references.py | """Fix references
Revision ID: c6be4fe10acc
Revises:
Create Date: 2019-09-20 11:01:59.648463+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c6be4fe10acc'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
conn.execute("PRAGMA legacy_alter_table = TRUE")
for name, sql in conn.execute("SELECT name, sql FROM sqlite_master WHERE type = 'table'").fetchall():
if sql is not None and '__old"' in sql:
sql = sql.replace('__old"', '"')
index_sqls = []
for index_sql, in conn.execute("""
SELECT sql
FROM sqlite_master
WHERE type = 'index' AND tbl_name = ?
""", (name,)).fetchall():
if index_sql is not None:
index_sqls.append(index_sql)
params = {"table": f'"{name}"', "table_old": f'"{name}__old"'}
conn.execute("ALTER TABLE %(table)s RENAME TO %(table_old)s" % params)
conn.execute(sql)
conn.execute("INSERT INTO %(table)s SELECT * FROM %(table_old)s" % params)
conn.execute("DROP TABLE %(table_old)s" % params)
for index_sql in index_sqls:
conn.execute(index_sql)
conn.execute("PRAGMA legacy_alter_table = FALSE")
def downgrade():
pass
| 1,397 | Python | .py | 36 | 30.638889 | 105 | 0.592894 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,802 | 2020-05-29_16-06_remove_replication_dedup.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-05-29_16-06_remove_replication_dedup.py | """Remove replication dedup
Revision ID: 1432b666093e
Revises: b694f05c1169
Create Date: 2020-05-29 16:06:19.379976+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1432b666093e'
down_revision = 'b694f05c1169'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
try:
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.drop_column('repl_dedup')
except Exception:
# Might be already done by migrate113
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.add_column(sa.Column('repl_dedup', sa.BOOLEAN(), nullable=False))
# ### end Alembic commands ###
| 936 | Python | .py | 26 | 31.846154 | 82 | 0.702222 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,803 | 2019-11-20_00-04_graphite_separateinstances.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-20_00-04_graphite_separateinstances.py | """Graphite SeparateInstances
Revision ID: 987305d75e3a
Revises: d20ab6a17489
Create Date: 2019-11-20 00:04:21.095499+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '987305d75e3a'
down_revision = 'd20ab6a17489'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_reporting', schema=None) as batch_op:
batch_op.add_column(sa.Column('graphite_separateinstances', sa.Boolean(), nullable=True))
op.execute("UPDATE system_reporting SET graphite_separateinstances = 0")
with op.batch_alter_table('system_reporting', schema=None) as batch_op:
batch_op.alter_column('graphite_separateinstances',
existing_type=sa.BOOLEAN(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_reporting', schema=None) as batch_op:
batch_op.drop_column('graphite_separateinstances')
# ### end Alembic commands ###
| 1,154 | Python | .py | 27 | 38.111111 | 97 | 0.716592 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,804 | 2020-01-22_19-28_drop_iscsi_initiator_tag.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-01-22_19-28_drop_iscsi_initiator_tag.py | """Drop iSCSI initiator tag column
Revision ID: 536cbfca20e6
Revises: f3875acb8d76
Create Date: 2020-01-22 19:28:06.324970+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '536cbfca20e6'
down_revision = 'f3875acb8d76'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_iscsitargetauthorizedinitiator', schema=None) as batch_op:
batch_op.drop_column('iscsi_target_initiator_tag')
def downgrade():
pass
| 500 | Python | .py | 16 | 28.75 | 98 | 0.777311 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,805 | 2019-12-29_14-09_kmip.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-12-29_14-09_kmip.py | """KMIP Support
Revision ID: c0f121844b00
Revises: f4e2434ad7f1
Create Date: 2019-12-29 14:09:29.127830+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c0f121844b00'
down_revision = 'f4e2434ad7f1'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'system_kmip',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('server', sa.String(length=128), nullable=True),
sa.Column('port', sa.SmallInteger(), nullable=False),
sa.Column('certificate_id', sa.Integer(), nullable=True),
sa.Column('certificate_authority_id', sa.Integer(), nullable=True),
sa.Column('manage_sed_disks', sa.Boolean(), nullable=False),
sa.Column('manage_zfs_keys', sa.Boolean(), nullable=False),
sa.Column('enabled', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(
['certificate_id'], ['system_certificate.id'],
name=op.f('fk_system_kmip_certificate_id_system_certificate')
),
sa.ForeignKeyConstraint(
['certificate_authority_id'], ['system_certificateauthority.id'],
name=op.f('fk_system_kmip_certificate_authority_id_system_certificateauthority')
),
sa.PrimaryKeyConstraint('id', name=op.f('pk_system_kmip'))
)
with op.batch_alter_table('system_kmip', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_system_kmip_certificate_id'), ['certificate_id'], unique=False)
batch_op.create_index(
batch_op.f('ix_system_kmip_certificate_authority_id'), ['certificate_authority_id'], unique=False
)
with op.batch_alter_table('storage_disk', schema=None) as batch_op:
batch_op.add_column(sa.Column('disk_kmip_uid', sa.String(length=255), nullable=True, default=None))
batch_op.alter_column('disk_passwd', existing_type=sa.CHAR, type_=sa.TEXT)
with op.batch_alter_table('storage_encrypteddataset', schema=None) as batch_op:
batch_op.add_column(sa.Column('kmip_uid', sa.String(length=255), nullable=True, default=None))
with op.batch_alter_table('system_advanced', schema=None) as batch_op:
batch_op.add_column(sa.Column('adv_kmip_uid', sa.String(length=255), nullable=True, default=None))
batch_op.alter_column('adv_sed_passwd', existing_type=sa.CHAR, type_=sa.TEXT)
def downgrade():
pass
| 2,431 | Python | .py | 48 | 43.916667 | 109 | 0.68086 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,806 | 2020-10-02_13-41_interface_link_address.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-10-02_13-41_interface_link_address.py | """Network interface link address
Revision ID: b410e4d0145f
Revises: a3298f120609
Create Date: 2020-10-02 13:41:27.024460+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b410e4d0145f'
down_revision = 'a3298f120609'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.add_column(sa.Column('int_link_address', sa.String(length=17), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.drop_column('int_link_address')
# ### end Alembic commands ###
| 861 | Python | .py | 22 | 35.863636 | 95 | 0.722557 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,807 | 2020-05-04_21-19_iscsi_vendor.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-05-04_21-19_iscsi_vendor.py | """
iSCSI Vendor configuration
Revision ID: 22230265ab30
Revises: 43779dce3a07
Create Date: 2020-05-04 21:19:22.658721-07:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '22230265ab30'
down_revision = '43779dce3a07'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_iscsitargetextent', schema=None) as batch_op:
batch_op.add_column(sa.Column('iscsi_target_extent_vendor', sa.TEXT(), nullable=True))
conn = op.get_bind()
for extent in conn.execute("SELECT * FROM services_iscsitargetextent").fetchall():
conn.execute("UPDATE services_iscsitargetextent SET iscsi_target_extent_vendor = ? WHERE id = ?", (
'FreeBSD' if extent['iscsi_target_extent_legacy'] else None, extent['id']
))
with op.batch_alter_table('services_iscsitargetextent', schema=None) as batch_op:
batch_op.drop_column('iscsi_target_extent_legacy')
| 979 | Python | .py | 23 | 38.608696 | 107 | 0.733122 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,808 | 2020-05-28_12-16_remove-ds-sysctls.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-05-28_12-16_remove-ds-sysctls.py | """Remove legacy freenas sysctls
Revision ID: 85346ccd33c0
Revises: ffcd02f6af9f
Create Date: 2020-05-28 16:29:33.277126+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '85346ccd33c0'
down_revision = 'ffcd02f6af9f'
branch_labels = None
depends_on = None
TABLE = 'system_tunable'
def remove_freenas_sysctls():
conn = op.get_bind()
conn.execute(
f'DELETE FROM {TABLE}'
' WHERE tun_var'
' LIKE "freenas.%"'
)
def upgrade():
remove_freenas_sysctls()
| 532 | Python | .py | 21 | 22 | 45 | 0.713147 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,809 | 2020-03-11_14-38_add-restrict-pam-to-ad.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-03-11_14-38_add-restrict-pam-to-ad.py | """Add ad_restrict_pam key
Revision ID: 32f55c715352
Revises: 8f874e6e40bc
Create Date: 2020-03-11 14:38:45.857258+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '32f55c715352'
down_revision = '8f874e6e40bc'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('directoryservice_activedirectory', schema=None) as batch_op:
batch_op.add_column(sa.Column('ad_restrict_pam', sa.Boolean(), nullable=True))
op.execute("UPDATE directoryservice_activedirectory SET ad_restrict_pam = 0")
with op.batch_alter_table('directoryservice_activedirectory', schema=None) as batch_op:
batch_op.alter_column('ad_restrict_pam', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('directoryservice_activedirectory', schema=None) as batch_op:
batch_op.drop_column('ad_restrict_pam')
# ### end Alembic commands ###
| 1,113 | Python | .py | 25 | 40.8 | 91 | 0.732342 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,810 | 2020-01-23_10-22_simplify_smb_shares.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-01-23_10-22_simplify_smb_shares.py | """Simplify SMB shares
Revision ID: bc290fddc888
Revises: 536cbfca20e6
Create Date: 2020-01-16 19:16:53.973957+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'bc290fddc888'
down_revision = '536cbfca20e6'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
"""
Move VFS objects into new boolean values. If users have a non-standard
set, append them as auxilary parameters to the SMB share to preseve
existing configuration. Same for other columns that are being dropped.
This will preserve existing share behavior post-migration.
"""
standard_vfs_objects = ['ixnas', 'streams_xattr', 'fruit', 'catia']
fruit_enabled = False
has_acl = True
has_streams =False
has_catia = False
set_durable = True
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.add_column(sa.Column('cifs_srv_aapl_extensions', sa.Boolean(), nullable=True))
batch_op.drop_column('cifs_srv_aio_enable')
batch_op.drop_column('cifs_srv_aio_rs')
batch_op.drop_column('cifs_srv_aio_ws')
with op.batch_alter_table('sharing_cifs_share', schema=None) as batch_op:
batch_op.add_column(sa.Column('cifs_purpose', sa.String(length=255), nullable=True))
batch_op.add_column(sa.Column('cifs_acl', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('cifs_aapl_name_mangling', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('cifs_path_suffix', sa.String(length=255), nullable=True))
batch_op.add_column(sa.Column('cifs_streams', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('cifs_durablehandle', sa.Boolean(), nullable=True))
conn = op.get_bind()
smb_shares = [dict(row) for row in conn.execute("SELECT * FROM sharing_cifs_share").fetchall()]
for share in smb_shares:
aux_params = share.get('cifs_auxsmbconf', '').split('\n')
vfs_objects = share.get('cifs_vfsobjects', '')
has_nondefault_vfs_objects = False
aux_updated = False
for v in vfs_objects.split(','):
if v not in standard_vfs_objects:
set_durable = False
has_nondefault_vfs_objects = True
if v == 'fruit':
fruit_enabled = True
if v == 'streams_xattr':
has_streams = True
if v == 'noacl':
has_acl = False
if v == 'catia':
has_catia = True
if share['cifs_timemachine']:
fruit_enabled = True
if share['cifs_showhiddenfiles']:
aux_params.append('hide dot files = no')
if share['cifs_guestonly']:
aux_params.append('guest only = yes')
if has_nondefault_vfs_objects:
aux_params.append(f"vfs objects = {vfs_objects.replace(',', ' ')}")
new_aux = '\n'.join(aux_params)
conn.execute("UPDATE sharing_cifs_share SET cifs_acl = :acl, cifs_streams = :streams, "
"cifs_aapl_name_mangling = :catia, cifs_durablehandle= :durable, "
"cifs_path_suffix = '', cifs_auxsmbconf = :aux, cifs_purpose = 'NO_PRESET' "
"WHERE id=:share_id", acl=has_acl, streams=has_streams, catia=has_catia,
durable=set_durable, aux=new_aux, share_id=share['id'])
op.execute(f"UPDATE services_cifs SET cifs_srv_aapl_extensions = {fruit_enabled}")
with op.batch_alter_table('sharing_cifs_share', schema=None) as batch_op:
batch_op.drop_column('cifs_vfsobjects')
batch_op.drop_column('cifs_showhiddenfiles')
batch_op.drop_column('cifs_guestonly')
with op.batch_alter_table('sharing_cifs_share', schema=None) as batch_op:
batch_op.alter_column('cifs_purpose', nullable=False)
batch_op.alter_column('cifs_acl', nullable=False)
batch_op.alter_column('cifs_streams', nullable=False)
batch_op.alter_column('cifs_path_suffix', nullable=False)
batch_op.alter_column('cifs_aapl_name_mangling', nullable=False)
batch_op.alter_column('cifs_durablehandle', nullable=False)
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.alter_column('cifs_srv_aapl_extensions', nullable=False)
# ### end Alembic commands ###
| 4,432 | Python | .py | 86 | 43 | 99 | 0.645631 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,811 | 2020-01-28_00-31_add-smb-flag-to-accounts.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-01-28_00-31_add-smb-flag-to-accounts.py | """Add SMB flag to users and groups
Revision ID: 4abbf75347b2
Revises: f6a18dec20fa
Create Date: 2020-01-28 00:31:27.730182+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4abbf75347b2'
down_revision = 'f6a18dec20fa'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdgrp_smb', sa.Boolean(), nullable=True))
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdusr_smb', sa.Boolean(), nullable=True))
op.execute("UPDATE account_bsdgroups SET bsdgrp_smb = 1 WHERE bsdgrp_builtin = 0")
op.execute("UPDATE account_bsdusers SET bsdusr_smb = 1 WHERE bsdusr_builtin = 0")
op.execute("UPDATE account_bsdgroups SET bsdgrp_smb = 0 WHERE bsdgrp_builtin = 1")
op.execute("UPDATE account_bsdusers SET bsdusr_smb = 0 WHERE bsdusr_builtin = 1")
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.alter_column('bsdgrp_smb', nullable=False)
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.alter_column('bsdusr_smb', nullable=False)
# ### end Alembic commands ###
| 1,381 | Python | .py | 27 | 47.074074 | 86 | 0.725987 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,812 | 2019-10-30_16-04_remove_legacy_ui_field.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-10-30_16-04_remove_legacy_ui_field.py | """Remove legacy UI field
Revision ID: 7f8be1364037
Revises: a87f7ecc4e88
Create Date: 2019-10-30 16:04:12.138197+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '7f8be1364037'
down_revision = 'a87f7ecc4e88'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('system_advanced', schema=None) as batch_op:
batch_op.drop_column('adv_legacy_ui')
def downgrade():
pass
| 454 | Python | .py | 16 | 25.875 | 74 | 0.75814 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,813 | 2019-10-26_20-24_migrate_legacy_replication.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-10-26_20-24_migrate_legacy_replication.py | """Migrate legacy replication
Revision ID: a87f7ecc4e88
Revises: ed69a9a6fab1
Create Date: 2019-10-26 20:24:27.220287+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a87f7ecc4e88'
down_revision = '6d65fd64e91c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("UPDATE storage_replication SET repl_transport = 'SSH' WHERE repl_transport = 'LEGACY'")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 667 | Python | .py | 20 | 30.75 | 103 | 0.7277 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,814 | 2019-12-19_15-02_alert_last_occurrence.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-12-19_15-02_alert_last_occurrence.py | """Alert last_occurrence
Revision ID: f4e2434ad7f1
Revises: 17fe2353a0de
Create Date: 2019-12-19 15:02:01.421499+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f4e2434ad7f1'
down_revision = '17fe2353a0de'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_alert', schema=None) as batch_op:
batch_op.add_column(sa.Column('last_occurrence', sa.DateTime(), nullable=True))
op.execute("UPDATE system_alert SET last_occurrence = datetime")
with op.batch_alter_table('system_alert', schema=None) as batch_op:
batch_op.alter_column('last_occurrence',
existing_type=sa.DATETIME(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_alert', schema=None) as batch_op:
batch_op.drop_column('last_occurrence')
# ### end Alembic commands ###
| 1,098 | Python | .py | 27 | 36.037037 | 87 | 0.700661 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,815 | 2022-01-03_11-46_add_s3_console_bindport.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2022-01-03_11-46_add_s3_console_bindport.py | """
Add s3 console bindport
Revision ID: 37298ef77ee8
Revises: 9c11f6c6f152
Create Date: 2022-01-03 11:46:50.848183+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '37298ef77ee8'
down_revision = '9c11f6c6f152'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_s3', schema=None) as batch_op:
batch_op.add_column(sa.Column('s3_console_bindport', sa.SmallInteger(), nullable=False, server_default='9001'))
def downgrade():
with op.batch_alter_table('services_s3', schema=None) as batch_op:
batch_op.drop_column('s3_console_bindport')
| 663 | Python | .py | 19 | 32.263158 | 119 | 0.753532 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,816 | 2020-05-29_14-52_run_migration_on_install.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-05-29_14-52_run_migration_on_install.py | """Run data migration on install / factory reset
Revision ID: b694f05c1169
Revises: a3ac49efb063
Create Date: 2020-05-29 14:52:52.049932+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b694f05c1169'
down_revision = 'a3ac49efb063'
branch_labels = None
depends_on = None
def upgrade():
op.execute("REPLACE INTO system_keyvalue (key, value) VALUES ('run_migration', 'true')")
def downgrade():
pass
| 473 | Python | .py | 16 | 27.5625 | 92 | 0.770601 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,817 | 2019-11-19_21-04_cert_revoked.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-19_21-04_cert_revoked.py | """Certificates revocation
Revision ID: d20ab6a17489
Revises: f2e8d8e7fd57
Create Date: 2019-11-19 21:04:49.865264+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd20ab6a17489'
down_revision = 'f2e8d8e7fd57'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_certificate', schema=None) as batch_op:
batch_op.add_column(sa.Column('cert_revoked_date', sa.DateTime(), nullable=True))
with op.batch_alter_table('system_certificateauthority', schema=None) as batch_op:
batch_op.add_column(sa.Column('cert_revoked_date', sa.DateTime(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_certificateauthority', schema=None) as batch_op:
batch_op.drop_column('cert_revoked_date')
with op.batch_alter_table('system_certificate', schema=None) as batch_op:
batch_op.drop_column('cert_revoked_date')
# ### end Alembic commands ###
| 1,165 | Python | .py | 26 | 40.884615 | 89 | 0.723159 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,818 | 2020-08-07_12-39_fix_smb_builtins.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-08-07_12-39_fix_smb_builtins.py | """Make sure builtin users are not smb users
Revision ID: 28ecea8be3fb
Revises: 6d3efdc7ba5b
Create Date: 2020-08-07 12:39:23.535263+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '28ecea8be3fb'
down_revision = '6d3efdc7ba5b'
branch_labels = None
depends_on = None
def upgrade():
op.execute("UPDATE account_bsdusers SET bsdusr_smb = 0 WHERE bsdusr_builtin = 1")
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 563 | Python | .py | 18 | 28.944444 | 85 | 0.746741 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,819 | 2019-11-28_20-37_disk_hddstandby_force.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-28_20-37_disk_hddstandby_force.py | """Add disk HDD Standby force option
Revision ID: dcf5c178714b
Revises: aa9810be100c
Create Date: 2019-11-28 20:37:01.292027+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dcf5c178714b'
down_revision = 'aa9810be100c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_disk', schema=None) as batch_op:
batch_op.add_column(sa.Column('disk_hddstandby_force', sa.Boolean(), nullable=True))
op.execute("UPDATE storage_disk SET disk_hddstandby_force = 0")
with op.batch_alter_table('storage_disk', schema=None) as batch_op:
batch_op.alter_column('disk_hddstandby_force',
existing_type=sa.BOOLEAN(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_disk', schema=None) as batch_op:
batch_op.drop_column('disk_hddstandby_force')
# ### end Alembic commands ###
| 1,125 | Python | .py | 27 | 37.037037 | 92 | 0.701657 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,820 | 2019-11-20_12-22_vm_normalize.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-20_12-22_vm_normalize.py | """Normalize VM models
Revision ID: aa9810be100c
Revises: bbedeabf94c7
Create Date: 2019-11-20 12:22:11.823446+00:00
"""
import json
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'aa9810be100c'
down_revision = 'bbedeabf94c7'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.add_column(sa.Column('cores', sa.INTEGER(), nullable=True))
batch_op.add_column(sa.Column('threads', sa.INTEGER(), nullable=True))
batch_op.add_column(sa.Column('shutdown_timeout', sa.INTEGER(), nullable=True))
op.execute("UPDATE vm_vm SET cores = 1, threads = 1, shutdown_timeout = 90")
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.alter_column('cores',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('threads',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('shutdown_timeout',
existing_type=sa.INTEGER(),
nullable=False)
conn = op.get_bind()
# ensure vnc port
all_ports = [6000, 6100]
vnc_devices = [dict(row) for row in conn.execute("SELECT * FROM vm_device WHERE dtype = 'VNC'").fetchall()]
for vnc_device in vnc_devices:
vnc_device['attributes'] = json.loads(vnc_device['attributes'])
if vnc_device['attributes'].get('vnc_port'):
try:
port = int(vnc_device['attributes']['vnc_port'])
except ValueError:
vnc_device['attributes']['vnc_port'] = None
else:
if port in all_ports or port < 5900 or port > 65535:
vnc_device['attributes']['vnc_port'] = None
else:
vnc_device['attributes']['vnc_port'] = port
all_ports.append(port)
for vnc_device in vnc_devices:
if not vnc_device['attributes'].get('vnc_port'):
port = next((i for i in range(5900, 65535) if i not in all_ports))
all_ports.append(port)
vnc_device['attributes']['vnc_port'] = port
if not vnc_device['attributes'].get('vnc_bind'):
# This is to ensure old users have this as a default value
vnc_device['attributes']['vnc_bind'] = '0.0.0.0'
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (
json.dumps(vnc_device['attributes']), vnc_device['id']
))
# add physical sector size support
for device in conn.execute("SELECT * FROM vm_device WHERE dtype IN ('DISK', 'RAW')").fetchall():
attributes = json.loads(device['attributes'])
try:
sector_size = int(attributes.pop('sectorsize', None))
if sector_size not in [512, 4096]:
raise ValueError('Invalid sector size')
except (ValueError, TypeError):
sector_size = None
attributes.update({
'logical_sectorsize': sector_size,
'physical_sectorsize': None,
})
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (json.dumps(attributes), device['id']))
# normalize_mac_address
for device in conn.execute("SELECT * FROM vm_device WHERE dtype = 'NIC'").fetchall():
attributes = json.loads(device['attributes'])
if not attributes.get('mac') or attributes['mac'] == '00:a0:98:FF:FF:FF':
attributes['mac'] = None
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (json.dumps(attributes), device['id']))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.drop_column('cores')
batch_op.drop_column('threads')
batch_op.drop_column('shutdown_timeout')
# ### end Alembic commands ###
| 4,079 | Python | .py | 86 | 38.209302 | 116 | 0.610747 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,821 | 2020-08-14_08-32_disk_zfs_guid.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-08-14_08-32_disk_zfs_guid.py | """Disk ZFS GUID
Revision ID: a3298f120609
Revises: 28ecea8be3fb
Create Date: 2020-08-14 08:32:33.852879+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a3298f120609'
down_revision = '28ecea8be3fb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_disk', schema=None) as batch_op:
batch_op.add_column(sa.Column('disk_zfs_guid', sa.String(length=20), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_disk', schema=None) as batch_op:
batch_op.drop_column('disk_zfs_guid')
# ### end Alembic commands ###
| 826 | Python | .py | 22 | 34.272727 | 92 | 0.711587 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,822 | 2019-11-20_12-03_system_advanced_syslog.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-20_12-03_system_advanced_syslog.py | """Move syslog to advanced settings
Revision ID: 350a31cb0769
Revises: ef898631896b
Create Date: 2019-11-20 12:03:35.382256+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '350a31cb0769'
down_revision = 'ef898631896b'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_advanced', schema=None) as batch_op:
batch_op.add_column(sa.Column('adv_sysloglevel', sa.String(length=120), nullable=True))
batch_op.add_column(sa.Column('adv_syslogserver', sa.String(length=120), nullable=True))
batch_op.add_column(sa.Column('adv_syslog_transport', sa.String(length=12), nullable=True))
batch_op.add_column(sa.Column('adv_syslog_tls_certificate_id', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_system_advanced_adv_syslog_tls_certificate_id'), ['adv_syslog_tls_certificate_id'], unique=False)
batch_op.create_foreign_key(batch_op.f('fk_system_advanced_adv_syslog_tls_certificate_id_system_certificate'), 'system_certificate', ['adv_syslog_tls_certificate_id'], ['id'])
op.execute("UPDATE system_advanced SET adv_sysloglevel = (SELECT stg_sysloglevel FROM system_settings)")
op.execute("UPDATE system_advanced SET adv_syslogserver = (SELECT stg_syslogserver FROM system_settings)")
op.execute("UPDATE system_advanced SET adv_syslog_transport = 'UDP'")
with op.batch_alter_table('system_advanced', schema=None) as batch_op:
batch_op.alter_column('adv_sysloglevel',
existing_type=sa.VARCHAR(120),
nullable=False)
batch_op.alter_column('adv_syslogserver',
existing_type=sa.VARCHAR(120),
nullable=False)
batch_op.alter_column('adv_syslog_transport',
existing_type=sa.VARCHAR(12),
nullable=False)
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.drop_column('stg_sysloglevel')
batch_op.drop_column('stg_syslogserver')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 2,293 | Python | .py | 42 | 48.02381 | 183 | 0.698079 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,823 | 2019-11-20_12-14_init_shutdown_script_comment_script_text.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-20_12-14_init_shutdown_script_comment_script_text.py | """Init/Shutdown script text and comment
Revision ID: bbedeabf94c7
Revises: 350a31cb0769
Create Date: 2019-11-20 12:14:34.182278+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'bbedeabf94c7'
down_revision = '350a31cb0769'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_initshutdown', schema=None) as batch_op:
batch_op.add_column(sa.Column('ini_script_text', sa.TEXT(), nullable=True))
batch_op.add_column(sa.Column('ini_comment', sa.VARCHAR(length=255), nullable=True))
op.execute("UPDATE tasks_initshutdown SET ini_script_text = '', ini_comment = ''")
with op.batch_alter_table('tasks_initshutdown', schema=None) as batch_op:
batch_op.alter_column('ini_script_text',
existing_type=sa.TEXT(),
nullable=False)
batch_op.alter_column('ini_comment',
existing_type=sa.VARCHAR(255),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_initshutdown', schema=None) as batch_op:
batch_op.drop_column('ini_comment')
batch_op.drop_column('ini_script_text')
# ### end Alembic commands ###
| 1,401 | Python | .py | 32 | 38.03125 | 92 | 0.681651 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,824 | 2021-02-23_11-54_sudo_nopasswd_commands.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2021-02-23_11-54_sudo_nopasswd_commands.py | """User/Group passwordless sudo, sudo commands allowlist
Revision ID: dc143ce20fcd
Revises: ae629228373b
Create Date: 2021-02-23 11:54:59.512053+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dc143ce20fcd'
down_revision = 'ae629228373b'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdgrp_sudo_commands', sa.TEXT(), nullable=False, server_default='[]'))
batch_op.add_column(sa.Column('bsdgrp_sudo_nopasswd', sa.Boolean(), nullable=False, server_default='0'))
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdusr_sudo_commands', sa.TEXT(), nullable=False, server_default='[]'))
batch_op.add_column(sa.Column('bsdusr_sudo_nopasswd', sa.Boolean(), nullable=False, server_default='0'))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.drop_column('bsdusr_sudo_nopasswd')
batch_op.drop_column('bsdusr_sudo_commands')
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.drop_column('bsdgrp_sudo_nopasswd')
batch_op.drop_column('bsdgrp_sudo_commands')
# ### end Alembic commands ###
| 1,551 | Python | .py | 30 | 47.1 | 112 | 0.711067 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,825 | 2020-03-30_10-09_overprovision.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-03-30_10-09_overprovision.py | """Overprovision
Revision ID: 29e866803c47
Revises: 38773ca83199
Create Date: 2020-03-30 10:09:52.863338+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '29e866803c47'
down_revision = '38773ca83199'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_advanced', schema=None) as batch_op:
batch_op.add_column(sa.Column('adv_overprovision', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_advanced', schema=None) as batch_op:
batch_op.drop_column('adv_overprovision')
# ### end Alembic commands ###
| 832 | Python | .py | 22 | 34.545455 | 88 | 0.72 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,826 | 2020-04-16_07-59_truecommand.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-04-16_07-59_truecommand.py | """
TrueCommand Service Model
Revision ID: 58339783792c
Revises: 171f5b91c36e
Create Date: 2020-04-06 07:59:08.663553+00:00
"""
from alembic import op
import sqlalchemy as sa
revision = '58339783792c'
down_revision = '171f5b91c36e'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'system_truecommand',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('api_key', sa.TEXT(), nullable=True),
sa.Column('api_key_state', sa.String(length=128), nullable=True),
sa.Column('wg_public_key', sa.String(length=255), nullable=True),
sa.Column('wg_private_key', sa.TEXT(), nullable=True),
sa.Column('wg_address', sa.String(length=255), nullable=True),
sa.Column('tc_public_key', sa.String(length=255), nullable=True),
sa.Column('endpoint', sa.String(length=255), nullable=True),
sa.Column('remote_address', sa.String(length=255), nullable=True),
sa.Column('enabled', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_system_truecommand'))
)
def downgrade():
pass
| 1,122 | Python | .py | 29 | 33.689655 | 74 | 0.682028 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,827 | 2020-06-01_16-18_smb-add-next-rid.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-06-01_16-18_smb-add-next-rid.py | """Add next_rid column to services_cifs
Revision ID: 5a365c7248da
Revises: 85346ccd33c0
Create Date: 2020-06-01 16:18:06.005627+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5a365c7248da'
down_revision = '85346ccd33c0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.add_column(sa.Column('cifs_srv_next_rid', sa.Integer(), nullable=True))
op.execute('UPDATE services_cifs SET cifs_srv_next_rid=0')
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.alter_column('cifs_srv_next_rid', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.drop_column('cifs_srv_next_rid')
# ### end Alembic commands ###
| 1,056 | Python | .py | 25 | 38.52 | 88 | 0.713445 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,828 | 2019-11-20_00-09_stg_guihttpsprotocols.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-20_00-09_stg_guihttpsprotocols.py | """HTTPs protocols
Revision ID: ef898631896b
Revises: 987305d75e3a
Create Date: 2019-11-20 00:09:06.241796+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ef898631896b'
down_revision = '987305d75e3a'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.add_column(sa.Column('stg_guihttpsprotocols', sa.TEXT(), nullable=True))
op.execute("""
UPDATE system_settings SET stg_guihttpsprotocols = '["TLSv1.2", "TLSv1.3"]'
""")
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.alter_column('stg_guihttpsprotocols',
existing_type=sa.TEXT(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.drop_column('stg_guihttpsprotocols1')
# ### end Alembic commands ###
| 1,154 | Python | .py | 29 | 35.034483 | 89 | 0.691203 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,829 | 2020-05-01_10-55_fix_smb_bindip.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-05-01_10-55_fix_smb_bindip.py | """Convert SMB bindip not null
Revision ID: 43779dce3a07
Revises: 2ab85192c49f
Create Date: 2020-05-01 10:55:52.386403+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '43779dce3a07'
down_revision = '2ab85192c49f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("UPDATE services_cifs SET cifs_srv_bindip = '' WHERE cifs_srv_bindip IS NULL")
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.alter_column('cifs_srv_bindip',
existing_type=sa.VARCHAR(length=250),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.alter_column('cifs_srv_bindip',
existing_type=sa.VARCHAR(length=250),
nullable=True)
# ### end Alembic commands ###
| 1,062 | Python | .py | 27 | 34.111111 | 93 | 0.684878 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,830 | 2020-12-10_20-38_replication_config.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-12-10_20-38_replication_config.py | """Replication config
Revision ID: ae629228373b
Revises: 90b815426c10
Create Date: 2020-12-10 20:38:57.399180+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ae629228373b'
down_revision = '90b815426c10'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('storage_replication_config',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('max_parallel_replication_tasks', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_storage_replication_config'))
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('storage_replication_config')
# ### end Alembic commands ###
| 857 | Python | .py | 24 | 32.708333 | 77 | 0.721212 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,831 | 2019-11-08_19-36_replication_replicate.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-08_19-36_replication_replicate.py | """Complete filesystem replicate option
Revision ID: 8b5d36242d44
Revises: 7e8f7f07153e
Create Date: 2019-11-08 19:36:27.373757+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8b5d36242d44'
down_revision = '7e8f7f07153e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.add_column(sa.Column('repl_replicate', sa.Boolean(), nullable=True))
op.execute("UPDATE storage_replication SET repl_replicate = 0")
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.alter_column('repl_replicate',
existing_type=sa.BOOLEAN(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.drop_column('repl_replicate')
# ### end Alembic commands ###
| 1,127 | Python | .py | 27 | 37.148148 | 85 | 0.707989 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,832 | 2019-09-20_11-02_fix_booleans.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-09-20_11-02_fix_booleans.py | """Fix booleans
Revision ID: d38e9cc6174c
Revises: a3423860aea0
Create Date: 2019-09-27 08:20:13.391318+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e49fadd7285d'
down_revision = 'c6be4fe10acc'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
for table_name, in conn.execute("SELECT name FROM sqlite_master WHERE type = 'table'").fetchall():
for column in conn.execute(f"PRAGMA TABLE_INFO('{table_name}')"):
if column["type"].lower() in ("bool", "boolean"):
op.execute(f"UPDATE {table_name} SET {column['name']} = 1 WHERE {column['name']} IN ('1', 'true') COLLATE NOCASE")
op.execute(f"UPDATE {table_name} SET {column['name']} = 0 WHERE {column['name']} != 1 AND {column['name']} IS NOT NULL")
def downgrade():
pass
| 879 | Python | .py | 21 | 37.428571 | 136 | 0.670588 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,833 | 2020-04-29_18-10_encrypt_ssh_and_certificates_private_keys.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-04-29_18-10_encrypt_ssh_and_certificates_private_keys.py | """Encrypt SSH and certificates private keys
Revision ID: 2ab85192c49f
Revises: 83dae64197f3
Create Date: 2020-04-29 18:10:31.488781+00:00
"""
from alembic import op
import sqlalchemy as sa
from middlewared.plugins.pwenc import encrypt
# revision identifiers, used by Alembic.
revision = '2ab85192c49f'
down_revision = '83dae64197f3'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
if not (
conn.execute("SELECT * FROM system_keyvalue WHERE key = 'has_0039_auto_20200429_0631' AND value = 'true'").
fetchall()
):
for table, fields in [
("services_snmp", ["snmp_v3_password", "snmp_v3_privpassphrase"]),
("services_ssh", ["ssh_privatekey", "ssh_host_dsa_key", "ssh_host_ecdsa_key", "ssh_host_ed25519_key",
"ssh_host_key", "ssh_host_rsa_key"]),
("services_s3", ["s3_secret_key"]),
("system_certificate", ["cert_privatekey"]),
("system_certificateauthority", ["cert_privatekey"]),
]:
for row in conn.execute(f"SELECT * FROM {table}").fetchall():
set_ = []
params = []
for k in fields:
if row[k] is not None:
set_.append(f"{k} = ?")
params.append(encrypt(row[k]))
if set_:
conn.execute(f"UPDATE {table} SET {', '.join(set_)} WHERE id = {row['id']}", params)
conn.execute("DELETE FROM system_keyvalue WHERE key = 'has_0039_auto_20200429_0631'")
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 1,715 | Python | .py | 41 | 32.707317 | 115 | 0.580878 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,834 | 2020-01-24_13-34_simplify_idmap_backends.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-01-24_13-34_simplify_idmap_backends.py | """Simplify and clean up idmap backends
Revision ID: f6a18dec20fa
Revises: bc290fddc888
Create Date: 2020-01-24 13:34:04.998905+00:00
"""
from alembic import op
import sqlalchemy as sa
import json
# revision identifiers, used by Alembic.
revision = 'f6a18dec20fa'
down_revision = 'bc290fddc888'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
conn = op.get_bind()
m = {}
highest_seen = 0
configured_domains = [dict(row) for row in conn.execute("SELECT * FROM directoryservice_idmap_domaintobackend").fetchall()]
for domain in configured_domains:
m[domain['idmap_dtb_domain_id']] = {}
backend = domain['idmap_dtb_idmap_backend']
dom = domain['idmap_dtb_domain_id']
idmap_table = f"directoryservice_idmap_{backend}"
backend_data = [dict(row) for row in conn.execute(f"SELECT * FROM {idmap_table} WHERE "
f"idmap_{backend}_domain_id = ?", dom).fetchall()]
m[dom]['backend'] = backend
if not backend_data:
m[dom].update({
'range_low': None,
'range_high': None,
})
continue
prefix_len = len(f"idmap_{backend}_")
for k, v in backend_data[0].items():
if k == 'id' or k[prefix_len:] == 'domain_id':
continue
m[dom].update({k[prefix_len:]: v})
if m[dom]['range_high'] > highest_seen:
highest_seen = m[dom]['range_high']
op.drop_table('directoryservice_idmap_script')
op.drop_table('directoryservice_idmap_tdb')
op.drop_table('directoryservice_idmap_rid')
op.drop_table('directoryservice_idmap_ad')
with op.batch_alter_table('directoryservice_idmap_rfc2307', schema=None) as batch_op:
batch_op.drop_index('ix_directoryservice_idmap_rfc2307_idmap_rfc2307_certificate_id')
op.drop_table('directoryservice_idmap_rfc2307')
with op.batch_alter_table('directoryservice_idmap_ldap', schema=None) as batch_op:
batch_op.drop_index('ix_directoryservice_idmap_ldap_idmap_ldap_certificate_id')
op.drop_table('directoryservice_idmap_ldap')
op.drop_table('directoryservice_idmap_domaintobackend')
op.drop_table('directoryservice_idmap_nss')
op.drop_table('directoryservice_idmap_autorid')
with op.batch_alter_table('directoryservice_activedirectory', schema=None) as batch_op:
batch_op.drop_column('ad_idmap_backend')
with op.batch_alter_table('directoryservice_ldap', schema=None) as batch_op:
batch_op.drop_column('ldap_idmap_backend')
with op.batch_alter_table('directoryservice_idmap_domain', schema=None) as batch_op:
batch_op.add_column(sa.Column('idmap_domain_certificate_id', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('idmap_domain_idmap_backend', sa.String(length=120), nullable=True))
batch_op.add_column(sa.Column('idmap_domain_options', sa.TEXT(), nullable=True))
batch_op.add_column(sa.Column('idmap_domain_range_high', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('idmap_domain_range_low', sa.Integer(), nullable=True))
for domain, params in m.items():
range_low = params.pop('range_low')
range_high = params.pop('range_high')
certificate_id = params.pop('certificate_id', '')
if range_low is None:
range_low = highest_seen + 1
range_high = highest_seen + 100000000
backend = params.pop('backend')
conn.execute("UPDATE directoryservice_idmap_domain SET idmap_domain_idmap_backend = :backend, "
"idmap_domain_range_low = :low, idmap_domain_range_high = :high, "
"idmap_domain_certificate_id = :cert, idmap_domain_options = :opts "
"WHERE idmap_domain_name= :dom",
low=range_low, high=range_high, backend=backend, cert=certificate_id,
opts=json.dumps(params) if params else '', dom=domain)
with op.batch_alter_table('directoryservice_idmap_domain', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_directoryservice_idmap_domain_idmap_domain_certificate_id'), ['idmap_domain_certificate_id'], unique=False)
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_domain_idmap_domain_certificate_id_system_certificate'), 'system_certificate', ['idmap_domain_certificate_id'], ['id'])
batch_op.alter_column('idmap_domain_idmap_backend', nullable=False)
batch_op.alter_column('idmap_domain_options', nullable=False)
batch_op.alter_column('idmap_domain_range_low', nullable=False)
batch_op.alter_column('idmap_domain_range_high', nullable=False)
# ### end Alembic commands ###
| 4,854 | Python | .py | 85 | 48.235294 | 193 | 0.662945 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,835 | 2019-11-19_20-41_openvpn.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-19_20-41_openvpn.py | """OpenVPN client and server
Revision ID: 115caec86b91
Revises: 8b5d36242d44
Create Date: 2019-11-19 20:41:34.620255+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '115caec86b91'
down_revision = '8b5d36242d44'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('services_openvpnclient',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('port', sa.Integer(), nullable=False),
sa.Column('protocol', sa.String(length=4), nullable=False),
sa.Column('device_type', sa.String(length=4), nullable=False),
sa.Column('nobind', sa.Boolean(), nullable=False),
sa.Column('authentication_algorithm', sa.String(length=32), nullable=True),
sa.Column('tls_crypt_auth', sa.Text(), nullable=True),
sa.Column('cipher', sa.String(length=32), nullable=True),
sa.Column('compression', sa.String(length=32), nullable=True),
sa.Column('additional_parameters', sa.Text(), nullable=False),
sa.Column('client_certificate_id', sa.Integer(), nullable=True),
sa.Column('root_ca_id', sa.Integer(), nullable=True),
sa.Column('remote', sa.String(length=120), nullable=False),
sa.ForeignKeyConstraint(['client_certificate_id'], ['system_certificate.id'], name=op.f('fk_services_openvpnclient_client_certificate_id_system_certificate')),
sa.ForeignKeyConstraint(['root_ca_id'], ['system_certificateauthority.id'], name=op.f('fk_services_openvpnclient_root_ca_id_system_certificateauthority')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_services_openvpnclient'))
)
with op.batch_alter_table('services_openvpnclient', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_services_openvpnclient_client_certificate_id'), ['client_certificate_id'], unique=False)
batch_op.create_index(batch_op.f('ix_services_openvpnclient_root_ca_id'), ['root_ca_id'], unique=False)
op.create_table('services_openvpnserver',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('port', sa.Integer(), nullable=False),
sa.Column('protocol', sa.String(length=4), nullable=False),
sa.Column('device_type', sa.String(length=4), nullable=False),
sa.Column('authentication_algorithm', sa.String(length=32), nullable=True),
sa.Column('tls_crypt_auth', sa.Text(), nullable=True),
sa.Column('cipher', sa.String(length=32), nullable=True),
sa.Column('compression', sa.String(length=32), nullable=True),
sa.Column('additional_parameters', sa.Text(), nullable=False),
sa.Column('server_certificate_id', sa.Integer(), nullable=True),
sa.Column('root_ca_id', sa.Integer(), nullable=True),
sa.Column('server', sa.String(length=45), nullable=False),
sa.Column('topology', sa.String(length=16), nullable=True),
sa.Column('netmask', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['root_ca_id'], ['system_certificateauthority.id'], name=op.f('fk_services_openvpnserver_root_ca_id_system_certificateauthority')),
sa.ForeignKeyConstraint(['server_certificate_id'], ['system_certificate.id'], name=op.f('fk_services_openvpnserver_server_certificate_id_system_certificate')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_services_openvpnserver'))
)
with op.batch_alter_table('services_openvpnserver', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_services_openvpnserver_root_ca_id'), ['root_ca_id'], unique=False)
batch_op.create_index(batch_op.f('ix_services_openvpnserver_server_certificate_id'), ['server_certificate_id'], unique=False)
op.execute("INSERT INTO services_services (srv_service, srv_enable) VALUES ('openvpn_client', 0)")
op.execute("INSERT INTO services_services (srv_service, srv_enable) VALUES ('openvpn_server', 0)")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_openvpnserver', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_services_openvpnserver_server_certificate_id'))
batch_op.drop_index(batch_op.f('ix_services_openvpnserver_root_ca_id'))
op.drop_table('services_openvpnserver')
with op.batch_alter_table('services_openvpnclient', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_services_openvpnclient_root_ca_id'))
batch_op.drop_index(batch_op.f('ix_services_openvpnclient_client_certificate_id'))
op.drop_table('services_openvpnclient')
# ### end Alembic commands ###
| 4,609 | Python | .py | 71 | 60.084507 | 163 | 0.718736 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,836 | 2019-12-10_19-44_fix_idamp_foreign_keys.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-12-10_19-44_fix_idamp_foreign_keys.py | """Fix idmap foreign keys
Revision ID: 17fe2353a0de
Revises: dcf5c178714b
Create Date: 2019-12-10 19:44:44.434836+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '17fe2353a0de'
down_revision = 'dcf5c178714b'
branch_labels = None
depends_on = None
def create_foreign_key_no_null(*args, **kwargs):
# DELETE where foreign key relationship would be broken or is NULL
op.execute(f"DELETE FROM {args[1]} WHERE {args[3][0]} NOT IN (SELECT {args[4][0]} FROM {args[2]}) OR {args[3][0]} IS NULL")
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
create_foreign_key_no_null(None, 'directoryservice_idmap_ad', 'directoryservice_idmap_domain', ['idmap_ad_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_ad', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_ad_idmap_ad_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_ad_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
create_foreign_key_no_null(None, 'directoryservice_idmap_autorid', 'directoryservice_idmap_domain', ['idmap_autorid_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_autorid', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_autorid_idmap_autorid_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_autorid_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
create_foreign_key_no_null(None, 'directoryservice_idmap_ldap', 'directoryservice_idmap_domain', ['idmap_ldap_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_ldap', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_ldap_idmap_ldap_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_ldap_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
create_foreign_key_no_null(None, 'directoryservice_idmap_nss', 'directoryservice_idmap_domain', ['idmap_nss_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_nss', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_nss_idmap_nss_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_nss_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
create_foreign_key_no_null(None, 'directoryservice_idmap_rfc2307', 'directoryservice_idmap_domain', ['idmap_rfc2307_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_rfc2307', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_rfc2307_idmap_rfc2307_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_rfc2307_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
create_foreign_key_no_null(None, 'directoryservice_idmap_rid', 'directoryservice_idmap_domain', ['idmap_rid_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_rid', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_rid_idmap_rid_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_rid_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
create_foreign_key_no_null(None, 'directoryservice_idmap_script', 'directoryservice_idmap_domain', ['idmap_script_domain_id'], ['idmap_domain_name'])
with op.batch_alter_table('directoryservice_idmap_script', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_directoryservice_idmap_script_idmap_script_domain_id_directoryservice_idmap_domain'), 'directoryservice_idmap_domain', ['idmap_script_domain_id'], ['idmap_domain_name'], ondelete='CASCADE')
| 3,977 | Python | .py | 38 | 100.078947 | 243 | 0.747645 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,837 | 2019-11-19_20-47_nfs_srv_v4_domain.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-11-19_20-47_nfs_srv_v4_domain.py | """NFSv4 domain
Revision ID: 514ce6934952
Revises: 115caec86b91
Create Date: 2019-11-19 20:47:28.702007+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '514ce6934952'
down_revision = '115caec86b91'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_nfs', schema=None) as batch_op:
batch_op.add_column(sa.Column('nfs_srv_v4_domain', sa.String(length=120), nullable=True))
op.execute("UPDATE services_nfs SET nfs_srv_v4_domain = ''")
with op.batch_alter_table('services_nfs', schema=None) as batch_op:
batch_op.alter_column('nfs_srv_v4_domain',
existing_type=sa.VARCHAR(length=120),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_nfs', schema=None) as batch_op:
batch_op.drop_column('nfs_srv_v4_domain')
# ### end Alembic commands ###
| 1,108 | Python | .py | 27 | 36.407407 | 97 | 0.693171 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,838 | 2020-07-21_13-53_fix_migrations_state.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-07-21_13-53_fix_migrations_state.py | """Fix migrations state
Revision ID: 6d3efdc7ba5b
Revises: 25962b409a1e
Create Date: 2020-07-21 13:53:51.925362+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6d3efdc7ba5b'
down_revision = '25962b409a1e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_rsyncmod', schema=None) as batch_op:
batch_op.alter_column('rsyncmod_enabled',
existing_type=sa.BOOLEAN(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_rsyncmod', schema=None) as batch_op:
batch_op.alter_column('rsyncmod_enabled',
existing_type=sa.BOOLEAN(),
nullable=True)
# ### end Alembic commands ###
| 951 | Python | .py | 26 | 31.346154 | 76 | 0.681967 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,839 | 2020-04-29_18-07_remove_asigra.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-04-29_18-07_remove_asigra.py | """Remove asigra table
Revision ID: 83dae64197f3
Revises: 58339783792c
Create Date: 2020-04-29 18:07:43.037006+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '83dae64197f3'
down_revision = '58339783792c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('services_asigra')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('services_asigra',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('filesystem', sa.VARCHAR(length=255), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
| 783 | Python | .py | 24 | 29.625 | 68 | 0.712383 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,840 | 2019-09-20_14-24_drop_django_tables.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2019-09-20_14-24_drop_django_tables.py | """Drop Django tables
Revision ID: 0d545b21e189
Revises: c6be4fe10acc
Create Date: 2019-09-20 14:24:39.828978+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0d545b21e189'
down_revision = 'e49fadd7285d'
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 362 | Python | .py | 16 | 20.625 | 45 | 0.784024 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,841 | 2020-10-21_16-19_snmp_iftop.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-10-21_16-19_snmp_iftop.py | """SNMP iftop
Revision ID: c09a16ca3399
Revises: 56016e596321
Create Date: 2020-10-21 16:19:50.910413+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c09a16ca3399'
down_revision = '56016e596321'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_snmp', schema=None) as batch_op:
batch_op.add_column(sa.Column('snmp_iftop', sa.Boolean(), nullable=True))
op.execute("UPDATE services_snmp SET snmp_iftop = FALSE")
with op.batch_alter_table('services_snmp', schema=None) as batch_op:
batch_op.alter_column('snmp_iftop', nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_snmp', schema=None) as batch_op:
batch_op.drop_column('snmp_iftop')
# ### end Alembic commands ###
| 1,008 | Python | .py | 25 | 36.6 | 81 | 0.710608 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,842 | 2020-04-13_22-15_fix_replication_foreign_keys.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/12.0/2020-04-13_22-15_fix_replication_foreign_keys.py | """Fix replication foreign keys
Revision ID: 171f5b91c36e
Revises: 29e866803c47
Create Date: 2020-04-13 22:15:14.597949+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '171f5b91c36e'
down_revision = '29e866803c47'
branch_labels = None
depends_on = None
def create_foreign_key(*args, **kwargs):
op.execute(f"DELETE FROM {args[1]} WHERE {args[3][0]} NOT IN (SELECT {args[4][0]} FROM {args[2]})")
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
create_foreign_key(None, 'storage_replication_repl_periodic_snapshot_tasks', 'storage_replication', ['replication_id'], ['id'])
create_foreign_key(None, 'storage_replication_repl_periodic_snapshot_tasks', 'storage_task', ['task_id'], ['id'])
with op.batch_alter_table('storage_replication_repl_periodic_snapshot_tasks', schema=None) as batch_op:
batch_op.drop_references('replication_id')
batch_op.drop_references('task_id')
batch_op.create_index(batch_op.f('ix_storage_replication_repl_periodic_snapshot_tasks_replication_id'), ['replication_id'], unique=False)
batch_op.create_index(batch_op.f('ix_storage_replication_repl_periodic_snapshot_tasks_task_id'), ['task_id'], unique=False)
batch_op.create_foreign_key(batch_op.f('fk_storage_replication_repl_periodic_snapshot_tasks_replication_id_storage_replication'), 'storage_replication', ['replication_id'], ['id'], ondelete='CASCADE')
batch_op.create_foreign_key(batch_op.f('fk_storage_replication_repl_periodic_snapshot_tasks_task_id_storage_task'), 'storage_task', ['task_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication_repl_periodic_snapshot_tasks', schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f('fk_storage_replication_repl_periodic_snapshot_tasks_task_id_storage_task'), type_='foreignkey')
batch_op.drop_constraint(batch_op.f('fk_storage_replication_repl_periodic_snapshot_tasks_replication_id_storage_replication'), type_='foreignkey')
batch_op.create_foreign_key(None, 'storage_replication', ['replication_id'], ['id'])
batch_op.create_foreign_key(None, 'storage_task', ['task_id'], ['id'])
batch_op.drop_index(batch_op.f('ix_storage_replication_repl_periodic_snapshot_tasks_task_id'))
batch_op.drop_index(batch_op.f('ix_storage_replication_repl_periodic_snapshot_tasks_replication_id'))
# ### end Alembic commands ###
| 2,613 | Python | .py | 36 | 67.638889 | 208 | 0.721854 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,843 | 2024-08-16_16-23_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-08-16_16-23_merge.py | """Merge
Revision ID: d4d5d52be239
Revises: 504a7bd32680, 7b13df980355
Create Date: 2024-08-16 16:23:59.547731+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd4d5d52be239'
down_revision = ('504a7bd32680', '7b13df980355')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,844 | 2024-10-08_18-48_user_api_key.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-10-08_18-48_user_api_key.py | """Convert to user-linked tokens
Revision ID: 8ae49ac78d14
Revises: 85e5d349cdb1
Create Date: 2024-10-08 18:48:55.972115+00:00
"""
from alembic import op
import sqlalchemy as sa
import json
# revision identifiers, used by Alembic.
revision = '8ae49ac78d14'
down_revision = '85e5d349cdb1'
branch_labels = None
depends_on = None
DEFAULT_ALLOW_LIST = [{"method": "*", "resource": "*"}]
ENTRY_REVOKED = -1
def upgrade():
conn = op.get_bind()
to_revoke = []
for row in conn.execute("SELECT id, allowlist FROM account_api_key").fetchall():
try:
if json.loads(row['allowlist']) != DEFAULT_ALLOW_LIST:
to_revoke.append(str(row['id']))
except Exception:
to_revoke.append(str(row['id']))
with op.batch_alter_table('account_api_key', schema=None) as batch_op:
batch_op.add_column(sa.Column('user_identifier', sa.String(length=200), nullable=False, server_default='LEGACY_API_KEY'))
batch_op.add_column(sa.Column('expiry', sa.Integer(), nullable=False, server_default='0'))
batch_op.drop_column('allowlist')
conn.execute(f"UPDATE account_api_key SET expiry={ENTRY_REVOKED} WHERE id IN ({', '.join(to_revoke)});")
def downgrade():
pass
| 1,238 | Python | .py | 31 | 35.225806 | 129 | 0.68311 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,845 | 2024-10-04_18-09_add_nfs_rdma.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-10-04_18-09_add_nfs_rdma.py | """Add NFS RDMA configuration setting
Revision ID: 85e5d349cdb1
Revises: 5fe28eada969
Create Date: 2024-10-04 18:09:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '85e5d349cdb1'
down_revision = '5fe28eada969'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_nfs', schema=None) as batch_op:
batch_op.add_column(sa.Column('nfs_srv_rdma', sa.Boolean(), nullable=False, server_default='0'))
def downgrade():
pass
| 533 | Python | .py | 17 | 28.941176 | 104 | 0.759843 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,846 | 2024-10-21_11-00_virt_global.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-10-21_11-00_virt_global.py | """Global configuration for virtualization feature
Revision ID: dd6e581235b2
Revises: 504a7bd32680
Create Date: 2024-08-02 14:03:41.855489+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dd6e581235b2'
down_revision = '8ae49ac78d14'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('virt_global',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pool', sa.String(length=120), nullable=True),
sa.Column('bridge', sa.String(length=120), nullable=True),
sa.Column('v4_network', sa.String(length=120), nullable=True),
sa.Column('v6_network', sa.String(length=120), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_virt_global')),
sqlite_autoincrement=True
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('virt_global')
# ### end Alembic commands ###
| 1,052 | Python | .py | 28 | 34.285714 | 66 | 0.71063 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,847 | 2024-08-12_15-53_discoveryauth.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-08-12_15-53_discoveryauth.py | """Add iSCSI discoverauth
Flatten the per-portal discovery auth to a system-wide discovery auth.
Revision ID: 504a7bd32680
Revises: 5654da8713d1
Create Date: 2024-08-12 15:53:48.342351+00:00
"""
import json
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '504a7bd32680'
down_revision = '5654da8713d1'
branch_labels = None
depends_on = None
def upgrade():
op.create_table('services_iscsidiscoveryauth',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('iscsi_discoveryauth_authmethod', sa.String(length=120), nullable=False),
sa.Column('iscsi_discoveryauth_authgroup', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_services_iscsidiscoveryauth')),
sa.UniqueConstraint('iscsi_discoveryauth_authgroup', name=op.f('uq_services_iscsidiscoveryauth_iscsi_discoveryauth_authgroup')),
sqlite_autoincrement=True
)
conn = op.get_bind()
data = conn.execute("SELECT iscsi_target_portal_discoveryauthgroup, iscsi_target_portal_discoveryauthmethod, id FROM services_iscsitargetportal").fetchall()
# Migrate the data into the new table.
# - Mutual CHAP first.
mutual_chap_auth_groups = []
for authgroup, authmethod, _portal_id in data:
if authmethod == 'CHAP Mutual' and authgroup not in mutual_chap_auth_groups:
# Let's not carry around 'CHAP Mutual' anymore.
conn.execute('INSERT INTO services_iscsidiscoveryauth (iscsi_discoveryauth_authmethod, iscsi_discoveryauth_authgroup) VALUES ("CHAP_MUTUAL",?)', authgroup)
mutual_chap_auth_groups.append(authgroup)
# - Simple CHAP next.
simple_chap_auth_groups = []
for authgroup, authmethod, _portal_id in data:
if authmethod == 'CHAP' and authgroup not in mutual_chap_auth_groups + simple_chap_auth_groups:
conn.execute('INSERT INTO services_iscsidiscoveryauth (iscsi_discoveryauth_authmethod, iscsi_discoveryauth_authgroup) VALUES ("CHAP",?)', authgroup)
simple_chap_auth_groups.append(authgroup)
# Things to test
# 1. Do we have a mix of None and non-None?
# 2. If not, do we have more than one CHAP/Mutual CHAP
# 3. Do we have more than one Mutual CHAP peeruser/secret?
none_list = list(filter(lambda t: t[1] == 'None', data))
none_count = len(none_list)
non_none_count = len(mutual_chap_auth_groups) + len(simple_chap_auth_groups)
if none_count and non_none_count:
portal_id_strs = list(str(item[2]) for item in none_list)
none_ips = conn.execute("SELECT iscsi_target_portalip_ip FROM services_iscsitargetportalip WHERE iscsi_target_portalip_portal_id IN (?)", ','.join(portal_id_strs)).fetchall()
conn.execute("INSERT INTO system_keyvalue (\"key\", value) VALUES (?, ?)",
("ISCSIDiscoveryAuthMixed", json.dumps({'ips': [ip[0] for ip in none_ips]})))
elif non_none_count > 1:
conn.execute("INSERT INTO system_keyvalue (\"key\", value) VALUES (?, ?)",
("ISCSIDiscoveryAuthMultipleCHAP", json.dumps({})))
if mutual_chap_auth_groups:
if len(mutual_chap_auth_groups) == 1:
data = conn.execute(f"SELECT DISTINCT iscsi_target_auth_peeruser FROM services_iscsitargetauthcredential WHERE iscsi_target_auth_tag = {mutual_chap_auth_groups[0]} AND iscsi_target_auth_peeruser != ''").fetchall()
else:
tags = ','.join(str(x) for x in mutual_chap_auth_groups)
data = conn.execute(f"SELECT DISTINCT iscsi_target_auth_peeruser FROM services_iscsitargetauthcredential WHERE iscsi_target_auth_tag in ({tags}) AND iscsi_target_auth_peeruser != ''").fetchall()
if len(list(data)) > 1:
active_peeruser = data[0][0]
conn.execute("INSERT INTO system_keyvalue (\"key\", value) VALUES (?, ?)",
("ISCSIDiscoveryAuthMultipleMutualCHAP", json.dumps({'peeruser': active_peeruser})))
# Remove the obsolete columns
with op.batch_alter_table('services_iscsitargetportal', schema=None) as batch_op:
batch_op.drop_column('iscsi_target_portal_discoveryauthgroup')
batch_op.drop_column('iscsi_target_portal_discoveryauthmethod')
def downgrade():
pass
| 4,359 | Python | .py | 70 | 53.8 | 225 | 0.681956 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,848 | 2024-09-25_13-52_remove_truenas_customerinformation.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-09-25_13-52_remove_truenas_customerinformation.py | """Remove TrueNAS customer information
Revision ID: f449b425ad89
Revises: 6dedf12c1035
Create Date: 2024-09-25 13:52:07.834992+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f449b425ad89'
down_revision = '6dedf12c1035'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('truenas_customerinformation')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('truenas_customerinformation',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('data', sa.TEXT(), nullable=False),
sa.Column('updated_at', sa.DATETIME(), nullable=False),
sa.Column('sent_at', sa.DATETIME(), nullable=True),
sa.Column('form_dismissed', sa.BOOLEAN(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
| 983 | Python | .py | 27 | 33.185185 | 65 | 0.712025 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,849 | 2024-10-04_00-45_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-10-04_00-45_merge.py | """Merge
Revision ID: 5fe28eada969
Revises: f449b425ad89, 92b98613c498
Create Date: 2024-10-04 00:45:59.547731+00:00
"""
revision = '5fe28eada969'
down_revision = ('f449b425ad89', '92b98613c498')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 291 | Python | .py | 13 | 20.307692 | 48 | 0.761029 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,850 | 2024-09-05_22-58_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-09-05_22-58_merge.py | """Merge
Revision ID: 7b618b9ca77d
Revises: 9f51d0be7b07, c31881e67797
Create Date: 2024-09-04 00:35:59.547731+00:00
"""
revision = '7b618b9ca77d'
down_revision = ('9f51d0be7b07', 'c31881e67797')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 291 | Python | .py | 13 | 20.307692 | 48 | 0.761029 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,851 | 2024-09-12_23-57_remove_nfs_v4_v3owner.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-09-12_23-57_remove_nfs_v4_v3owner.py | """Remove deprecated v4_v3owner NFS configuration option
Revision ID: 6dedf12c1035
Revises: 7b618b9ca77d
Create Date: 2024-09-12 23:57:43.814512+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6dedf12c1035'
down_revision = '7b618b9ca77d'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_nfs', schema=None) as batch_op:
batch_op.drop_column('nfs_srv_v4_v3owner')
def downgrade():
pass
| 512 | Python | .py | 17 | 27.647059 | 71 | 0.771605 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,852 | 2024-09-04_00-35_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-09-04_00-35_merge.py | """Merge
Revision ID: 9f51d0be7b07
Revises: 991d17a5b3a2, 98c1ebde0079
Create Date: 2024-09-04 00:35:59.547731+00:00
"""
revision = '9f51d0be7b07'
down_revision = ('991d17a5b3a2', '98c1ebde0079')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 291 | Python | .py | 13 | 20.307692 | 48 | 0.761029 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,853 | 2024-09-02_16-54_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/25.04/2024-09-02_16-54_merge.py | """Merge
Revision ID: 991d17a5b3a2
Revises: d4d5d52be239, 7b13df980355
Create Date: 2024-09-02 16:54:59.547731+00:00
"""
revision = '991d17a5b3a2'
down_revision = ('d4d5d52be239', 'd24d6760fda4')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 291 | Python | .py | 13 | 20.307692 | 48 | 0.761029 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,854 | 2022-06-23_12-11_rsync_ssh_credentials.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-06-23_12-11_rsync_ssh_credentials.py | """rsync SSH credentials
Revision ID: 32a49386d6c3
Revises: 34df1ca8a04e
Create Date: 2022-05-31 12:11:48.231515+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '32a49386d6c3'
down_revision = '34df1ca8a04e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_rsync', schema=None) as batch_op:
batch_op.add_column(sa.Column('rsync_ssh_credentials_id', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_tasks_rsync_rsync_ssh_credentials_id'), ['rsync_ssh_credentials_id'], unique=False)
batch_op.create_foreign_key(batch_op.f('fk_tasks_rsync_rsync_ssh_credentials_id_system_keychaincredential'), 'system_keychaincredential', ['rsync_ssh_credentials_id'], ['id'])
batch_op.alter_column('rsync_remotehost',
existing_type=sa.VARCHAR(length=120),
nullable=True)
batch_op.alter_column('rsync_remotemodule',
existing_type=sa.VARCHAR(length=120),
nullable=True)
batch_op.alter_column('rsync_remoteport',
existing_type=sa.SMALLINT(),
nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_rsync', schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f('fk_tasks_rsync_rsync_ssh_credentials_id_system_keychaincredential'), type_='foreignkey')
batch_op.drop_index(batch_op.f('ix_tasks_rsync_rsync_ssh_credentials_id'))
batch_op.drop_column('rsync_ssh_credentials_id')
# ### end Alembic commands ###
| 1,769 | Python | .py | 35 | 43.914286 | 183 | 0.688334 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,855 | 2022-03-28_20-20_display_devices.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-03-28_20-20_display_devices.py | """
Normalize VM Display Device Port(s)
Revision ID: d46d345ef8a8
Revises: 696b3d876084
Create Date: 2022-03-28 20:20:11.823446+00:00
"""
import json
from alembic import op
revision = 'd46d345ef8a8'
down_revision = '696b3d876084'
branch_labels = None
depends_on = None
def get_web_port(port):
split_port = int(str(port)[:2]) - 1
return int(str(split_port) + str(port)[2:])
def upgrade():
conn = op.get_bind()
# ensure vnc port
display_devices = {
row['id']: json.loads(row['attributes'])
for row in map(dict, conn.execute("SELECT * FROM vm_device WHERE dtype = 'DISPLAY'").fetchall())
}
reserved_ports = [d['port'] for d in display_devices.values()] + [6000]
for display_id, display_device in display_devices.items():
web_port = get_web_port(display_device['port'])
while web_port in reserved_ports:
web_port += 1
display_device['web_port'] = web_port
reserved_ports.append(web_port)
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (
json.dumps(display_device), display_id
))
def downgrade():
pass
| 1,152 | Python | .py | 34 | 28.852941 | 104 | 0.657919 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,856 | 2022-05-27_12-30_cpu_pinning.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-05-27_12-30_cpu_pinning.py | """CPU Pinning
Revision ID: 0267cef97ec3
Revises: 59fbc9897ec3
Create Date: 2022-05-27 12:30:03.593598+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0267cef97ec3'
down_revision = '59fbc9897ec3'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.add_column(sa.Column('cpuset', sa.Text(), nullable=True))
batch_op.add_column(sa.Column('nodeset', sa.Text(), nullable=True))
batch_op.add_column(sa.Column('pin_vcpus', sa.Boolean(), nullable=False, server_default='0'))
def downgrade():
pass
| 664 | Python | .py | 19 | 31.842105 | 101 | 0.728414 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,857 | 2022-07-03_18-10_validate_host_paths.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-03_18-10_validate_host_paths.py | """
Add validate host path field
Revision ID: adb5c45a0383
Revises: 32a49386d6c3
Create Date: 2022-07-03 18:10:27.526805+00:00
"""
from alembic import op
import sqlalchemy as sa
revision = 'adb5c45a0383'
down_revision = '32a49386d6c3'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_kubernetes', schema=None) as batch_op:
batch_op.add_column(sa.Column('validate_host_path', sa.Boolean(), server_default='1', nullable=False))
def downgrade():
pass
| 513 | Python | .py | 17 | 27.764706 | 110 | 0.760246 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,858 | 2022-10-13_14-51_cloudsync_rsync_job_persist.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-10-13_14-51_cloudsync_rsync_job_persist.py | """Cloud sync and rsync tasks job persistence
Revision ID: dc9ffe67a56f
Revises: f0e551d2defc
Create Date: 2022-09-20 10:51:03.199209+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dc9ffe67a56f'
down_revision = 'f0e551d2defc'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_cloudsync', schema=None) as batch_op:
batch_op.add_column(sa.Column('job', sa.TEXT(), nullable=False, server_default="null"))
with op.batch_alter_table('tasks_rsync', schema=None) as batch_op:
batch_op.add_column(sa.Column('rsync_job', sa.TEXT(), nullable=False, server_default="null"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_rsync', schema=None) as batch_op:
batch_op.drop_column('rsync_job')
with op.batch_alter_table('tasks_cloudsync', schema=None) as batch_op:
batch_op.drop_column('job')
# ### end Alembic commands ###
| 1,142 | Python | .py | 26 | 40 | 101 | 0.707428 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,859 | 2022-06-08_11-50_hyperv_enlightenments.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-06-08_11-50_hyperv_enlightenments.py | """
Hyper-V enlightenments
Revision ID: afa3965ed8fc
Revises: 67d87d9cfc30
Create Date: 2022-06-08 11:50:50.818433+00:00
"""
from alembic import op
import sqlalchemy as sa
revision = 'afa3965ed8fc'
down_revision = '67d87d9cfc30'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.add_column(sa.Column('hyperv_enlightenments', sa.Boolean(), server_default='0', nullable=False))
def downgrade():
pass
| 495 | Python | .py | 17 | 26.764706 | 113 | 0.757962 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,860 | 2022-07-11_17-49_merge_migration.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-11_17-49_merge_migration.py | """Merge migration post acltemplate comment addition
Revision ID: 0feebf8ad1ed
Revises: adb5c45a0383, 1c8a45c2ec20
Create Date: 2022-07-11 17:49:00.772568+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0feebf8ad1ed'
down_revision = ('adb5c45a0383', '1c8a45c2ec20')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 425 | Python | .py | 16 | 24.5625 | 52 | 0.790524 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,861 | 2022-10-07_21-31_update_usb_pass_through_params.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-10-07_21-31_update_usb_pass_through_params.py | """update usb pass through params
Revision ID: d388b0e9a50d
Revises: 7a74a8933a30
Create Date: 2022-10-07 21:31:21.541782+00:00
"""
from alembic import op
import json
revision = 'd388b0e9a50d'
down_revision = '7a74a8933a30'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
devices = {
row['id']: json.loads(row['attributes'])
for row in map(dict, conn.execute("SELECT * FROM vm_device WHERE dtype = 'USB'").fetchall())
}
for device_id, device_attrs in devices.items():
device_attrs.update({
'controller_type': 'nec-xhci',
'usb': None,
})
conn.execute('UPDATE vm_device SET attributes = ? WHERE id = ?', (
json.dumps(device_attrs), device_id
))
def downgrade():
pass
| 804 | Python | .py | 27 | 24.62963 | 100 | 0.643693 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,862 | 2022-05-28_20-30_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-05-28_20-30_merge.py | """
Merge Migration
Revision ID: a719566695c3
Revises: 59fbc9897ec3, 8b6d0edc6a38
Create Date: 2022-05-28 20:30:01.759559+00:00
"""
revision = 'a719566695c3'
down_revision = ('59fbc9897ec3', '8b6d0edc6a38')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 303 | Python | .py | 14 | 19.571429 | 48 | 0.765957 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,863 | 2023-03-15_15-59_migrate_hostname_virtual_to_netbiosname.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-03-15_15-59_migrate_hostname_virtual_to_netbiosname.py | """ Replacing netbiosname with hostname_virtual as needed
Revision ID: 3df90537bffa
Revises: b690e5ae986d
Create Date: 2023-03-15 15:59:58.605407+00:00
"""
from alembic import op
import sqlalchemy as sa
import re
# revision identifiers, used by Alembic.
revision = '3df90537bffa'
down_revision = 'b690e5ae986d'
branch_labels = None
depends_on = None
RE_NETBIOSNAME = re.compile(r"^[a-zA-Z0-9\.\-_!@#\$%^&\(\)'\{\}~]{1,15}$")
def upgrade():
conn = op.get_bind()
ngc = dict(conn.execute('SELECT * FROM network_globalconfiguration').fetchone())
if not ngc['gc_hostname_virtual']:
return
if not RE_NETBIOSNAME.match(ngc['gc_hostname_virtual']):
return
conn.execute('UPDATE services_cifs SET cifs_srv_netbiosname = ?', ngc['gc_hostname_virtual'])
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 915 | Python | .py | 26 | 31.961538 | 97 | 0.701934 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,864 | 2023-05-10_13-44_repl_encryption_inherit.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-05-10_13-44_repl_encryption_inherit.py | """Replication encryption inherit
Revision ID: 08539dfd0500
Revises: 7035fa70c0c0
Create Date: 2023-05-10 13:44:25.770294+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '08539dfd0500'
down_revision = '7035fa70c0c0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.add_column(sa.Column('repl_encryption_inherit', sa.Boolean(), nullable=True))
op.execute("UPDATE storage_replication SET repl_encryption_inherit = 0 WHERE repl_encryption = 1")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.drop_column('repl_encryption_inherit')
# ### end Alembic commands ###
| 973 | Python | .py | 23 | 38.913043 | 102 | 0.731629 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,865 | 2022-12-19_08-31_fix_migrations_state.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-12-19_08-31_fix_migrations_state.py | """Fix migrations state
Revision ID: 136adf794fed
Revises: fa4097ef2236
Create Date: 2022-12-19 08:31:55.475116+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '136adf794fed'
down_revision = 'fa4097ef2236'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.drop_column('cifs_srv_netbiosname_b')
with op.batch_alter_table('storage_task', schema=None) as batch_op:
batch_op.drop_column('task_state')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_task', schema=None) as batch_op:
batch_op.add_column(sa.Column('task_state', sa.TEXT(), server_default=sa.text("'{}'"), nullable=False))
with op.batch_alter_table('services_cifs', schema=None) as batch_op:
batch_op.add_column(sa.Column('cifs_srv_netbiosname_b', sa.VARCHAR(length=120), nullable=True))
# ### end Alembic commands ###
| 1,156 | Python | .py | 26 | 40.538462 | 111 | 0.707513 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,866 | 2022-05-31_12-06_int_address_b_not_null.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-05-31_12-06_int_address_b_not_null.py | """int_address_b is NOT NULL
Revision ID: 6e185504ffb5
Revises: 9df2ef0f7f32
Create Date: 2022-05-31 12:06:32.400919+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6e185504ffb5'
down_revision = '9df2ef0f7f32'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.alter_column('int_address_b',
existing_type=sa.VARCHAR(length=45),
nullable=False,
existing_server_default=sa.text("('')"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.alter_column('int_address_b',
existing_type=sa.VARCHAR(length=45),
nullable=True,
existing_server_default=sa.text("('')"))
# ### end Alembic commands ###
| 1,082 | Python | .py | 28 | 32.642857 | 77 | 0.66092 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,867 | 2022-09-05_14-05_update_media_user_builtin_after_update.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-09-05_14-05_update_media_user_builtin_after_update.py | """Update media user builtin after update
Revision ID: aef1177c39c5
Revises: eba33d756a77
Create Date: 2022-09-05 14:17:54.745653+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'aef1177c39c5'
down_revision = 'eba33d756a77'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
con = op.get_bind()
con.execute('UPDATE account_bsdusers SET bsdusr_builtin=0 WHERE bsdusr_username="media"')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 693 | Python | .py | 21 | 30.285714 | 93 | 0.725904 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,868 | 2022-03-01_14-40_simplify_network_interfaces.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-03-01_14-40_simplify_network_interfaces.py | """simplify network_interfaces table
Revision ID: a2ae33484fed
Revises: 4c852b54dfa1
Create Date: 2022-03-01 14:40:25.351989+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a2ae33484fed'
down_revision = '4c852b54dfa1'
branch_labels = None
depends_on = None
def create_new_entries(old_entry):
new_entry = {}
alias_entry = {}
if old_entry['int_ipv4address'] and old_entry['int_ipv6address']:
# this shouldn't happen but we'll play it safe
# we'll write the ipv4 address to the network_interface table
new_entry['id'] = old_entry['id']
new_entry['int_address'] = old_entry['int_ipv4address']
new_entry['int_address_b'] = old_entry['int_ipv4address_b']
new_entry['int_version'] = 4
new_entry['int_netmask'] = int(old_entry['int_v4netmaskbit']) if old_entry['int_v4netmaskbit'] else 32
# we'll write the ipv6 address to the network_alias table
alias_entry['alias_interface_id'] = old_entry['id']
alias_entry['alias_address'] = old_entry['int_ipv6address']
alias_entry['alias_address_b'] = old_entry['int_ipv6address_b']
alias_entry['alias_vip'] = old_entry['int_vipv6address'] or ''
alias_entry['alias_version'] = 6
alias_entry['alias_netmask'] = int(old_entry['int_v6netmaskbit']) if old_entry['int_v6netmaskbit'] else 128
elif old_entry['int_ipv4address']:
new_entry['id'] = old_entry['id']
new_entry['int_address'] = old_entry['int_ipv4address']
new_entry['int_address_b'] = old_entry['int_ipv4address_b']
new_entry['int_version'] = 4
new_entry['int_netmask'] = int(old_entry['int_v4netmaskbit']) if old_entry['int_v4netmaskbit'] else 32
elif old_entry['int_ipv6address']:
new_entry['id'] = old_entry['id']
new_entry['int_address'] = old_entry['int_ipv6address']
new_entry['int_address_b'] = old_entry['int_ipv6address_b']
new_entry['int_vip'] = old_entry['int_vipv6address']
new_entry['int_version'] = 6
new_entry['int_netmask'] = int(old_entry['int_v6netmaskbit']) if old_entry['int_v6netmaskbit'] else 128
return new_entry, alias_entry
def upgrade():
con = op.get_bind()
new_entries = []
for old_entry in map(dict, con.execute('SELECT * FROM network_interfaces').fetchall()):
new_entries.append(create_new_entries(old_entry))
# add new columns
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.add_column(sa.Column('int_address', sa.String(length=45), server_default='', nullable=False))
batch_op.add_column(sa.Column('int_address_b', sa.String(length=45), server_default='', nullable=True))
batch_op.add_column(sa.Column('int_netmask', sa.Integer(), server_default='', nullable=False))
batch_op.add_column(sa.Column('int_version', sa.Integer(), server_default='', nullable=False))
# update new columns
for new_entry, alias_entry in new_entries:
if new_entry:
_id = new_entry.pop('id')
for column, value in new_entry.items():
con.execute(f'UPDATE network_interfaces SET {column} = "{value}" WHERE id = "{_id}"')
if alias_entry:
columns = tuple(alias_entry.keys())
values = tuple(alias_entry.values())
con.execute(f'INSERT INTO network_alias {columns} VALUES {values}')
# remove old columns
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.drop_column('int_ipv6address_b')
batch_op.drop_column('int_ipv6address')
batch_op.drop_column('int_vipv6address')
batch_op.drop_column('int_ipv4address')
batch_op.drop_column('int_v4netmaskbit')
batch_op.drop_column('int_v6netmaskbit')
batch_op.drop_column('int_ipv4address_b')
def downgrade():
with op.batch_alter_table('network_interfaces', schema=None) as batch_op:
batch_op.add_column(sa.Column('int_ipv4address_b', sa.VARCHAR(length=42), nullable=False))
batch_op.add_column(sa.Column('int_v6netmaskbit', sa.VARCHAR(length=3), nullable=False))
batch_op.add_column(sa.Column('int_v4netmaskbit', sa.VARCHAR(length=3), nullable=False))
batch_op.add_column(sa.Column('int_ipv4address', sa.VARCHAR(length=42), nullable=False))
batch_op.add_column(sa.Column('int_vipv6address', sa.VARCHAR(length=45), nullable=True))
batch_op.add_column(sa.Column('int_ipv6address', sa.VARCHAR(length=45), nullable=False))
batch_op.add_column(sa.Column('int_ipv6address_b', sa.VARCHAR(length=45), nullable=False))
batch_op.drop_column('int_version')
batch_op.drop_column('int_netmask')
batch_op.drop_column('int_address_b')
batch_op.drop_column('int_address')
| 4,865 | Python | .py | 87 | 48.551724 | 115 | 0.665617 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,869 | 2022-05-09_11-11_ui_allowlist.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-05-09_11-11_ui_allowlist.py | """ui_allowlist
Revision ID: 59fbc9897ec3
Revises: 1bd044af765d
Create Date: 2022-05-09 11:11:03.593598+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '59fbc9897ec3'
down_revision = '1bd044af765d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.add_column(sa.Column('stg_guiallowlist', sa.TEXT(), nullable=False, server_default='[]'))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.drop_column('stg_guiallowlist')
# ### end Alembic commands ###
| 848 | Python | .py | 22 | 35.272727 | 106 | 0.714461 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,870 | 2022-07-29_14-47_remove_ms_accounts.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-29_14-47_remove_ms_accounts.py | """ Remove MS account support
Revision ID: b44a453a8b3f
Revises: 14899f89b885
Create Date: 2022-07-29 14:47:35.977304+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b44a453a8b3f'
down_revision = '14899f89b885'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.drop_column('bsdusr_microsoft_account')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdusr_microsoft_account', sa.BOOLEAN(), nullable=False))
# ### end Alembic commands ###
| 862 | Python | .py | 22 | 35.909091 | 96 | 0.722892 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,871 | 2022-07-31_13-12_device_attribute_io.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-31_13-12_device_attribute_io.py | """iotype added
Revision ID: 9b7127606e2b
Revises: b44a453a8b3f
Create Date: 2022-07-31 13:12:33.727477+00:00
"""
import json
from alembic import op
# revision identifiers, used by Alembic.
revision = '9b7127606e2b'
down_revision = 'b44a453a8b3f'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
devices = {
row['id']: json.loads(row['attributes'])
for row in map(dict, conn.execute("SELECT * FROM vm_device WHERE dtype IN ('DISK', 'RAW')").fetchall())
}
for device_id, device in devices.items():
device['iotype'] = 'THREADS'
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (
json.dumps(device), device_id
))
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 857 | Python | .py | 27 | 27.407407 | 111 | 0.660976 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,872 | 2022-04-05_00-25_add_tun_orig_value.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-04-05_00-25_add_tun_orig_value.py | """add tunables_orig_value
Revision ID: 1bd044af765d
Revises: 6e73632d6e88
Create Date: 2022-04-05 00:25:56.744546+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1bd044af765d'
down_revision = '6e73632d6e88'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('system_tunable', schema=None) as batch_op:
batch_op.add_column(sa.Column('tun_orig_value', sa.String(length=512), server_default='', nullable=False))
nocase = 'COLLATE NOCASE'
op.execute(f'DELETE FROM system_tunable WHERE tun_type = "loader" {nocase} or tun_type = "rc" {nocase}')
conn = op.get_bind()
for entry in conn.execute('SELECT * FROM system_tunable WHERE tun_type = "sysctl" COLLATE NOCASE').fetchall():
# It's impossible to (easily) determine the default value of a sysctl tunable because
# of the order in which the upgrade service runs compared to systemd-sysctl service.
# We'll simply use the user-provided value to normalize the database. There is no
# change in functionality by doing it this way.
conn.execute('UPDATE system_tunable SET tun_orig_value = ? WHERE id = ?', (entry['tun_value'], entry['id']))
def downgrade():
pass
| 1,278 | Python | .py | 26 | 45 | 116 | 0.720612 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,873 | 2022-07-27_01-00_portal_ips.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-27_01-00_portal_ips.py | """
Migrate iSCSI Portal IPs
Revision ID: 14899f89b885
Revises: 75d84034adcb
Create Date: 2022-07-27 01:00:58.755371+00:00
"""
from collections import defaultdict
from alembic import op
import sqlalchemy as sa
revision = '14899f89b885'
down_revision = '75d84034adcb'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
with op.batch_alter_table('services_iscsitargetglobalconfiguration', schema=None) as batch_op:
batch_op.add_column(sa.Column('iscsi_listen_port', sa.INTEGER(), nullable=False, server_default='3260'))
ip_to_port_to_id = defaultdict(dict)
ports_popularity = defaultdict(int)
for row in map(dict, conn.execute("SELECT * FROM services_iscsitargetportalip").fetchall()):
ip_to_port_to_id[row['iscsi_target_portalip_ip']][row['iscsi_target_portalip_port']] = row['id']
ports_popularity[row['iscsi_target_portalip_port']] += 1
if '0.0.0.0' in ip_to_port_to_id:
if 3260 in ip_to_port_to_id['0.0.0.0']:
listen_port = 3260
else:
listen_port = min(ip_to_port_to_id['0.0.0.0'].keys())
elif ports_popularity:
listen_port = sorted(
ports_popularity.keys(),
key=lambda port: (
ports_popularity[port],
1 if port == 3260 else 0,
)
)[-1]
else:
listen_port = 3260
for ip, port_to_id in ip_to_port_to_id.items():
if listen_port in port_to_id:
leave_id = port_to_id[listen_port]
else:
leave_id = sorted(port_to_id.values())[0]
conn.execute("DELETE FROM services_iscsitargetportalip WHERE iscsi_target_portalip_ip = ? AND id != ?",
ip, leave_id)
conn.execute("UPDATE services_iscsitargetglobalconfiguration SET iscsi_listen_port = ?", listen_port)
with op.batch_alter_table('services_iscsitargetportalip', schema=None) as batch_op:
batch_op.create_index(
'services_iscsitargetportalip_iscsi_target_portalip_ip', ['iscsi_target_portalip_ip'], unique=True
)
batch_op.drop_index('services_iscsitargetportalip_iscsi_target_portalip_ip__iscsi_target_portalip_port')
batch_op.drop_column('iscsi_target_portalip_port')
def downgrade():
pass
| 2,286 | Python | .py | 53 | 35.867925 | 112 | 0.658251 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,874 | 2022-03-08_13-35_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-03-08_13-35_merge.py | """Merge
Revision ID: 53fc4f0a6ffc
Revises: 455ac50fe299, b3c5a5321aef
Create Date: 2020-10-23 14:36:28.587671+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '53fc4f0a6ffc'
down_revision = ('455ac50fe299', 'b3c5a5321aef')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,875 | 2023-06-14_09-27_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-06-14_09-27_merge.py | """Merge
Revision ID: 1490eef1fa8d
Revises: 441144fa08e7, b412304844e1
Create Date: 2023-06-14 09:27:30.734506+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1490eef1fa8d'
down_revision = ('441144fa08e7', 'b412304844e1')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,876 | 2023-01-18_10-11_sudo_nopasswd_commands.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-01-18_10-11_sudo_nopasswd_commands.py | """sudo nopasswd commands
Revision ID: 48d82c064ea2
Revises: 5b68832586f4
Create Date: 2023-01-18 10:11:13.876642+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '48d82c064ea2'
down_revision = '5b68832586f4'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdgrp_sudo_commands_nopasswd', sa.TEXT(), nullable=False, server_default="[]"))
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdusr_sudo_commands_nopasswd', sa.TEXT(), nullable=False, server_default="[]"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.drop_column('bsdusr_sudo_commands_nopasswd')
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.drop_column('bsdgrp_sudo_commands_nopasswd')
# ### end Alembic commands ###
| 1,225 | Python | .py | 26 | 43.153846 | 119 | 0.719224 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,877 | 2023-01-18_17-09_sudo_refactoring.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-01-18_17-09_sudo_refactoring.py | """sudo refactoring
Revision ID: 004f0934ff0f
Revises: 48d82c064ea2
Create Date: 2023-01-18 17:09:36.160574+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '004f0934ff0f'
down_revision = '48d82c064ea2'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
for table, prefix in [("account_bsdusers", "bsdusr_"), ("account_bsdgroups", "bsdgrp_")]:
op.execute(f"""
UPDATE {table}
SET {prefix}sudo_commands = '["ALL"]'
WHERE {prefix}sudo = 1 AND {prefix}sudo_commands = '[]'
""")
op.execute(f"""
UPDATE {table}
SET {prefix}sudo_commands_nopasswd = {prefix}sudo_commands, {prefix}sudo_commands = '[]'
WHERE {prefix}sudo = 1 AND {prefix}sudo_nopasswd = 1
""")
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.drop_column('bsdgrp_sudo_nopasswd')
batch_op.drop_column('bsdgrp_sudo')
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.drop_column('bsdusr_sudo')
batch_op.drop_column('bsdusr_sudo_nopasswd')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('account_bsdusers', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdusr_sudo_nopasswd', sa.BOOLEAN(), server_default=sa.text("'0'"), nullable=False))
batch_op.add_column(sa.Column('bsdusr_sudo', sa.BOOLEAN(), nullable=False))
with op.batch_alter_table('account_bsdgroups', schema=None) as batch_op:
batch_op.add_column(sa.Column('bsdgrp_sudo', sa.BOOLEAN(), nullable=False))
batch_op.add_column(sa.Column('bsdgrp_sudo_nopasswd', sa.BOOLEAN(), server_default=sa.text("'0'"), nullable=False))
# ### end Alembic commands ###
| 1,971 | Python | .py | 41 | 41.780488 | 123 | 0.660929 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,878 | 2022-08-17_09-28_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-08-17_09-28_merge.py | """Merge
Revision ID: e3a81e1c2135
Revises: 9b7127606e2b, 7c8da45b515e
Create Date: 2022-08-17 09:28:11.301224+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e3a81e1c2135'
down_revision = ('9b7127606e2b', '7c8da45b515e')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,879 | 2022-03-03_12-30_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-03-03_12-30_merge.py | """Merge
Revision ID: 77832a4aeca8
Revises: a2ae33484fed, c09a16ca3399
Create Date: 2020-10-23 14:36:28.587671+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '77832a4aeca8'
down_revision = ('a2ae33484fed', '2ed09f3b17b7')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,880 | 2023-02-07_10-33_autoincrement.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-02-07_10-33_autoincrement.py | """Re-create tables with `sqlite_autoincrement`
Revision ID: 1f39ac35aaeb
Revises: af5efb72c74f
Create Date: 2023-02-07 10:33:08.436590+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1f39ac35aaeb'
down_revision = 'af5efb72c74f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
conn = op.get_bind()
conn.execute("PRAGMA legacy_alter_table = TRUE")
for name, sql in conn.execute("SELECT name, sql FROM sqlite_master WHERE type = 'table'").fetchall():
if name in ["sqlite_sequence", "alembic_version"]:
continue
if "autoincrement" in sql.lower():
continue
with op.batch_alter_table(name, recreate='always'):
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 988 | Python | .py | 28 | 30.642857 | 105 | 0.68 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,881 | 2023-01-25_15-38_ssh_adminlogin.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-01-25_15-38_ssh_adminlogin.py | """ssh_adminlogin
Revision ID: af5efb72c74f
Revises: 004f0934ff0f
Create Date: 2023-01-25 15:38:53.058719+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'af5efb72c74f'
down_revision = '004f0934ff0f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_ssh', schema=None) as batch_op:
batch_op.add_column(sa.Column('ssh_adminlogin', sa.Boolean(), nullable=False, server_default="1"))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('services_ssh', schema=None) as batch_op:
batch_op.drop_column('ssh_adminlogin')
# ### end Alembic commands ###
| 842 | Python | .py | 22 | 35 | 106 | 0.714815 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,882 | 2022-05-31_12-02_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-05-31_12-02_merge.py | """Merge
Revision ID: bca4e75ed8fc
Revises: 0267cef97ec3, a719566695c3
Create Date: 2022-05-31 12:02:05.164214+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'bca4e75ed8fc'
down_revision = ('0267cef97ec3', 'a719566695c3')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,883 | 2022-08-30_18-00_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-08-30_18-00_merge.py | """Merge
Revision ID: eba33d756a77
Revises: daaf691ed483, 98b2cfaa0e5a
Create Date: 2022-08-30 18:00:11.301224+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'eba33d756a77'
down_revision = ('daaf691ed483', '98b2cfaa0e5a')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,884 | 2022-06-12_17-50_iscsi_target_networks.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-06-12_17-50_iscsi_target_networks.py | """
iSCSI Target authorized networks
Revision ID: 34df1ca8a04e
Revises: afa3965ed8fc
Create Date: 2022-06-12 17:50:03.593598+00:00
"""
import json
import sqlalchemy as sa
from alembic import op
revision = '34df1ca8a04e'
down_revision = 'afa3965ed8fc'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_iscsitarget', schema=None) as batch_op:
batch_op.add_column(sa.Column('iscsi_target_auth_networks', sa.TEXT(), nullable=False, server_default='[]'))
conn = op.get_bind()
target_groups = [
dict(row)
for row in conn.execute("""
SELECT *
FROM services_iscsitargetgroups
WHERE iscsi_target_initiatorgroup_id IS NOT NULL
""").fetchall()
]
for target_group in target_groups:
initiator = conn.execute(
"SELECT * FROM services_iscsitargetauthorizedinitiator WHERE id = ?",
[target_group['iscsi_target_initiatorgroup_id']]
).fetchone()
if initiator is None:
continue
initiator = dict(initiator)
auth_network = initiator['iscsi_target_initiator_auth_network']
conn.execute("UPDATE services_iscsitarget SET iscsi_target_auth_networks = ? WHERE id = ?", (
json.dumps([] if auth_network == 'ALL' else auth_network.split()),
target_group['iscsi_target_id']
))
with op.batch_alter_table('services_iscsitargetauthorizedinitiator', schema=None) as batch_op:
batch_op.drop_column('iscsi_target_initiator_auth_network')
def downgrade():
pass
| 1,599 | Python | .py | 42 | 31.47619 | 116 | 0.671855 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,885 | 2022-04-01_16-26_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-04-01_16-26_merge.py | """merge
Revision ID: 6e73632d6e88
Revises: d46d345ef8a8, 19eb67dcdee2
Create Date: 2022-04-01 17:28:01.759559+00:00
"""
# revision identifiers, used by Alembic.
revision = '6e73632d6e88'
down_revision = ('d46d345ef8a8', '19eb67dcdee2')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 333 | Python | .py | 14 | 21.714286 | 48 | 0.766026 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,886 | 2022-08-18_07-00_vm_pause.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-08-18_07-00_vm_pause.py | """
Add option to enable pausing vms when taking snapshot
Revision ID: daaf691ed483
Revises: 79942334975f
Create Date: 2022-08-18 07:00:09.81180300:00
"""
from alembic import op
import sqlalchemy as sa
revision = 'daaf691ed483'
down_revision = '79942334975f'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.add_column(sa.Column('suspend_on_snapshot', sa.Boolean(), nullable=False, server_default='0'))
def downgrade():
pass
| 524 | Python | .py | 17 | 28.411765 | 111 | 0.759519 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,887 | 2023-01-13_18-23_fix_tunable_type.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-01-13_18-23_fix_tunable_type.py | """upper-case tun_type column in system_tunable table
Revision ID: c86a02e21e9d
Revises: 5cc601ce9a8e
Create Date: 2023-01-13 18:23:46.735430+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c86a02e21e9d'
down_revision = '5cc601ce9a8e'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
conn.execute('UPDATE system_tunable SET tun_type = "SYSCTL" where tun_type = "sysctl"')
def downgrade():
pass
| 502 | Python | .py | 17 | 27.352941 | 91 | 0.763103 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,888 | 2022-10-12_10-41_replication_name_regex_custom_retention_policy.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-10-12_10-41_replication_name_regex_custom_retention_policy.py | """Remove CUSTOM retention policy from replication tasks that use name_regex
Revision ID: f0e551d2defc
Revises: ae2a519c8b9a
Create Date: 2022-10-12 10:41:03.028186+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f0e551d2defc'
down_revision = 'ae2a519c8b9a'
branch_labels = None
depends_on = None
def upgrade():
op.execute("""
UPDATE storage_replication
SET repl_retention_policy = 'NONE',
repl_lifetime_unit = NULL,
repl_lifetime_value = NULL,
repl_lifetimes = '[]'
WHERE repl_name_regex IS NOT NULL
""")
def downgrade():
pass
| 670 | Python | .py | 23 | 24.652174 | 76 | 0.701095 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,889 | 2022-10-08_09-21_vmware_pending_snapshot_delete.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-10-08_09-21_vmware_pending_snapshot_delete.py | """VMware pending snapshot delete
Revision ID: ae2a519c8b9a
Revises: d388b0e9a50d
Create Date: 2022-09-22 09:21:29.691045+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ae2a519c8b9a'
down_revision = 'd388b0e9a50d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('storage_vmwarependingsnapshotdelete',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('vmware', sa.Text(), nullable=False),
sa.Column('vm_uuid', sa.String(length=200), nullable=False),
sa.Column('snapshot_name', sa.String(length=200), nullable=False),
sa.Column('datetime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_storage_vmwarependingsnapshotdelete')),
sqlite_autoincrement=True
)
with op.batch_alter_table('storage_task', schema=None) as batch_op:
batch_op.add_column(sa.Column('task_state', sa.Text(), nullable=False, server_default='{}'))
with op.batch_alter_table('storage_vmwareplugin', schema=None) as batch_op:
batch_op.add_column(sa.Column('state', sa.TEXT(), nullable=False, server_default='{"state": "PENDING"}'))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_vmwareplugin', schema=None) as batch_op:
batch_op.drop_column('state')
with op.batch_alter_table('storage_task', schema=None) as batch_op:
batch_op.drop_column('task_state')
op.drop_table('storage_vmwarependingsnapshotdelete')
# ### end Alembic commands ###
| 1,699 | Python | .py | 36 | 42.972222 | 113 | 0.711084 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,890 | 2022-09-21_14-35_add_command_line_args.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-09-21_14-35_add_command_line_args.py | """Add command line args
Revision ID: 7a74a8933a30
Revises: aef1177c39c5
Create Date: 2022-09-21 17:47:51.657447+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7a74a8933a30'
down_revision = 'aef1177c39c5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.add_column(sa.Column('command_line_args', sa.TEXT(), nullable=False, server_default=''))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 731 | Python | .py | 21 | 31.809524 | 105 | 0.711429 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,891 | 2022-12-02_17-20_kubernetes_passthrough_mode.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-12-02_17-20_kubernetes_passthrough_mode.py | """
Kubernetes passthrough mode
Revision ID: fa4097ef2236
Revises: dc9ffe67a56f
Create Date: 2022-12-02 17:20:21.541782+00:00
"""
from alembic import op
import sqlalchemy as sa
revision = 'fa4097ef2236'
down_revision = 'dc9ffe67a56f'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('services_kubernetes', schema=None) as batch_op:
batch_op.add_column(sa.Column('passthrough_mode', sa.Boolean(), nullable=False, server_default='0'))
def downgrade():
pass
| 510 | Python | .py | 17 | 27.588235 | 108 | 0.764948 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,892 | 2022-08-17_13-37_privilege.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-08-17_13-37_privilege.py | """Account privileges
Revision ID: 79942334975f
Revises: e3a81e1c2135
Create Date: 2022-08-09 13:37:57.243188+00:00
"""
import json
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '79942334975f'
down_revision = 'e3a81e1c2135'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('account_privilege',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('builtin_name', sa.String(length=200), nullable=True),
sa.Column('name', sa.String(length=200), nullable=False),
sa.Column('local_groups', sa.TEXT(), nullable=False),
sa.Column('ds_groups', sa.TEXT(), nullable=False),
sa.Column('allowlist', sa.TEXT(), nullable=False),
sa.Column('web_shell', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_account_privilege')),
sqlite_autoincrement=True
)
conn = op.get_bind()
for row in conn.execute("SELECT * FROM account_bsdgroups WHERE bsdgrp_group = 'builtin_administrators'").fetchall():
builtin_administrators_id = row["id"]
break
else:
conn.execute("INSERT INTO account_bsdgroups (bsdgrp_gid, bsdgrp_group, bsdgrp_builtin, bsdgrp_sudo, bsdgrp_smb,"
"bsdgrp_sudo_commands, bsdgrp_sudo_nopasswd) VALUES (544, 'builtin_administrators', 1, 0, 1, '[]',"
"0)")
builtin_administrators_id = conn.execute("SELECT last_insert_rowid()").fetchone()[0]
root_id = conn.execute("SELECT * FROM account_bsdusers WHERE bsdusr_uid = 0").fetchone()["id"]
allowlist = [{"method": "*", "resource": "*"}]
op.execute("INSERT INTO account_privilege (builtin_name, name, local_groups, ds_groups, allowlist, web_shell) "
f"VALUES ('LOCAL_ADMINISTRATOR', 'Local Administrator', '[544]', '[]', '{json.dumps(allowlist)}', 1)")
if not list(conn.execute(
f"SELECT * FROM account_bsdgroupmembership WHERE bsdgrpmember_group_id = {builtin_administrators_id} AND "
f"bsdgrpmember_user_id = {root_id}"
).fetchall()):
op.execute(f"INSERT INTO account_bsdgroupmembership (bsdgrpmember_group_id, bsdgrpmember_user_id) VALUES "
f"({builtin_administrators_id}, {root_id})")
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.add_column(sa.Column('stg_ds_auth', sa.Boolean(), nullable=False, server_default='0'))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_settings', schema=None) as batch_op:
batch_op.drop_column('stg_ds_auth')
op.drop_table('account_privilege')
# ### end Alembic commands ###
| 2,806 | Python | .py | 54 | 46.018519 | 120 | 0.675557 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,893 | 2022-07-12_09-34_cloud_sync_create_empty_src_dirs.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-12_09-34_cloud_sync_create_empty_src_dirs.py | """Cloud sync create_empty_src_dirs
Revision ID: 3ac384af617f
Revises: 0feebf8ad1ed
Create Date: 2022-07-12 09:34:58.755371+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3ac384af617f'
down_revision = '0feebf8ad1ed'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_cloudsync', schema=None) as batch_op:
batch_op.add_column(sa.Column('create_empty_src_dirs', sa.Boolean(), nullable=True))
op.execute("UPDATE tasks_cloudsync SET create_empty_src_dirs = FALSE")
with op.batch_alter_table('tasks_cloudsync', schema=None) as batch_op:
batch_op.alter_column('create_empty_src_dirs',
existing_type=sa.BOOLEAN(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('tasks_cloudsync', schema=None) as batch_op:
batch_op.drop_column('create_empty_src_dirs')
# ### end Alembic commands ###
| 1,139 | Python | .py | 27 | 37.592593 | 92 | 0.702089 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,894 | 2023-03-22_17-35_cpu_in_percentage.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-03-22_17-35_cpu_in_percentage.py | """Remove cpu_in_percentage
Revision ID: 7035fa70c0c0
Revises: 3df90537bffa
Create Date: 2023-03-22 17:35:30.041076+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7035fa70c0c0'
down_revision = '3df90537bffa'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_reporting', schema=None) as batch_op:
batch_op.drop_column('cpu_in_percentage')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('system_reporting', schema=None) as batch_op:
batch_op.add_column(sa.Column('cpu_in_percentage', sa.BOOLEAN(), nullable=False))
# ### end Alembic commands ###
| 846 | Python | .py | 22 | 35.181818 | 89 | 0.718673 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,895 | 2023-01-16_ovmf_file.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2023-01-16_ovmf_file.py | """ovmf file
Revision ID: 67ee25d22253
Revises: c86a02e21e9d
Create Date: 2023-01-11 15:04:04.043297+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '67ee25d22253'
down_revision = 'c86a02e21e9d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('vm_vm', schema=None) as batch_op:
batch_op.add_column(sa.Column(
'bootloader_ovmf', sa.String(length=1024), nullable=False, server_default='OVMF_CODE.fd'
))
# ### end Alembic commands ###
def downgrade():
pass
| 662 | Python | .py | 21 | 28 | 100 | 0.710443 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,896 | 2022-12-30_13-21_fix_netcli_refs.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-12-30_13-21_fix_netcli_refs.py | """fix netcli references
Revision ID: 5cc601ce9a8e
Revises: 136adf794fed
Create Date: 2022-12-30 13:21:11.005256+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5cc601ce9a8e'
down_revision = '136adf794fed'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
conn.execute(
'UPDATE account_bsdusers SET bsdusr_shell = "/usr/sbin/nologin" WHERE bsdusr_shell LIKE "%netcli%"'
)
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
| 612 | Python | .py | 21 | 26.333333 | 107 | 0.723077 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,897 | 2022-07-26_17-20_ipv6_ndp_vms.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-07-26_17-20_ipv6_ndp_vms.py | """
Allow users to configure NDP for vms
Revision ID: 75d84034adcb
Revises: 3ac384af617f
Create Date: 2022-07-26 17:20:58.755371+00:00
"""
import json
from alembic import op
revision = '75d84034adcb'
down_revision = '3ac384af617f'
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
for row in map(dict, conn.execute("SELECT * FROM vm_device WHERE dtype = 'NIC'").fetchall()):
config = json.loads(row['attributes'])
config['trust_guest_rx_filters'] = False
conn.execute("UPDATE vm_device SET attributes = ? WHERE id = ?", (json.dumps(config), row['id']))
def downgrade():
pass
| 647 | Python | .py | 20 | 29 | 105 | 0.704545 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,898 | 2022-03-07_16-54_merge.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-03-07_16-54_merge.py | """Merge
Revision ID: 455ac50fe299
Revises: 77832a4aeca8, 4e027c93e4d1
Create Date: 2022-03-07 16:54:21.691455+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '455ac50fe299'
down_revision = ('77832a4aeca8', '4e027c93e4d1')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
| 381 | Python | .py | 16 | 21.8125 | 48 | 0.778711 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
23,899 | 2022-02-17_18-44_remove_ladvd.py | truenas_middleware/src/middlewared/middlewared/alembic/versions/22.12/2022-02-17_18-44_remove_ladvd.py | """remove ladvd service
Revision ID: 4c852b54dfa1
Revises: 7a143979d99b
Create Date: 2022-02-17 18:44:19.468377+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '4c852b54dfa1'
down_revision = '7a143979d99b'
branch_labels = None
depends_on = None
def upgrade():
op.drop_table('services_lldp')
op.execute('DELETE FROM services_services where srv_service = "lldp"')
def downgrade():
pass
| 441 | Python | .py | 16 | 25.3125 | 74 | 0.767386 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |