Verified Commit b3853e01 authored by Kevin Morris's avatar Kevin Morris
Browse files

fix(pre-commit): include migrations in fixes/checks



We want all python files related to the project to be checked, really.
Some of which are still included, but migrations are a core part of
FastAPI aurweb and should be included.

Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 03776c46
Pipeline #28777 passed with stages
in 2 minutes and 49 seconds
exclude: ^migrations/versions
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
......
......@@ -10,41 +10,41 @@ from alembic import op
import aurweb.config
# revision identifiers, used by Alembic.
revision = '56e2ce8e2ffa'
down_revision = 'ef39fcd6e1cd'
revision = "56e2ce8e2ffa"
down_revision = "ef39fcd6e1cd"
branch_labels = None
depends_on = None
# Tables affected by charset/collate change
tables = [
('AccountTypes', 'utf8mb4', 'utf8mb4_general_ci'),
('ApiRateLimit', 'utf8mb4', 'utf8mb4_general_ci'),
('Bans', 'utf8mb4', 'utf8mb4_general_ci'),
('DependencyTypes', 'utf8mb4', 'utf8mb4_general_ci'),
('Groups', 'utf8mb4', 'utf8mb4_general_ci'),
('Licenses', 'utf8mb4', 'utf8mb4_general_ci'),
('OfficialProviders', 'utf8mb4', 'utf8mb4_bin'),
('PackageBases', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageBlacklist', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageComments', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageDepends', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageKeywords', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageRelations', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageRequests', 'utf8mb4', 'utf8mb4_general_ci'),
('PackageSources', 'utf8mb4', 'utf8mb4_general_ci'),
('Packages', 'utf8mb4', 'utf8mb4_general_ci'),
('RelationTypes', 'utf8mb4', 'utf8mb4_general_ci'),
('RequestTypes', 'utf8mb4', 'utf8mb4_general_ci'),
('SSHPubKeys', 'utf8mb4', 'utf8mb4_bin'),
('Sessions', 'utf8mb4', 'utf8mb4_bin'),
('TU_VoteInfo', 'utf8mb4', 'utf8mb4_general_ci'),
('Terms', 'utf8mb4', 'utf8mb4_general_ci'),
('Users', 'utf8mb4', 'utf8mb4_general_ci')
("AccountTypes", "utf8mb4", "utf8mb4_general_ci"),
("ApiRateLimit", "utf8mb4", "utf8mb4_general_ci"),
("Bans", "utf8mb4", "utf8mb4_general_ci"),
("DependencyTypes", "utf8mb4", "utf8mb4_general_ci"),
("Groups", "utf8mb4", "utf8mb4_general_ci"),
("Licenses", "utf8mb4", "utf8mb4_general_ci"),
("OfficialProviders", "utf8mb4", "utf8mb4_bin"),
("PackageBases", "utf8mb4", "utf8mb4_general_ci"),
("PackageBlacklist", "utf8mb4", "utf8mb4_general_ci"),
("PackageComments", "utf8mb4", "utf8mb4_general_ci"),
("PackageDepends", "utf8mb4", "utf8mb4_general_ci"),
("PackageKeywords", "utf8mb4", "utf8mb4_general_ci"),
("PackageRelations", "utf8mb4", "utf8mb4_general_ci"),
("PackageRequests", "utf8mb4", "utf8mb4_general_ci"),
("PackageSources", "utf8mb4", "utf8mb4_general_ci"),
("Packages", "utf8mb4", "utf8mb4_general_ci"),
("RelationTypes", "utf8mb4", "utf8mb4_general_ci"),
("RequestTypes", "utf8mb4", "utf8mb4_general_ci"),
("SSHPubKeys", "utf8mb4", "utf8mb4_bin"),
("Sessions", "utf8mb4", "utf8mb4_bin"),
("TU_VoteInfo", "utf8mb4", "utf8mb4_general_ci"),
("Terms", "utf8mb4", "utf8mb4_general_ci"),
("Users", "utf8mb4", "utf8mb4_general_ci"),
]
# Indexes affected by charset/collate change
# Map of Unique Indexes key = index_name, value = [table_name, column1, column2]
indexes = {'ProviderNameProvides': ['OfficialProviders', 'Name', 'Provides']}
indexes = {"ProviderNameProvides": ["OfficialProviders", "Name", "Provides"]}
# Source charset/collation, before this migration is run.
src_charset = "utf8"
......
......@@ -19,8 +19,8 @@ from alembic import op
from sqlalchemy.dialects.mysql import INTEGER, TINYINT
# revision identifiers, used by Alembic.
revision = 'be7adae47ac3'
down_revision = '56e2ce8e2ffa'
revision = "be7adae47ac3"
down_revision = "56e2ce8e2ffa"
branch_labels = None
depends_on = None
......@@ -32,7 +32,7 @@ DOWNGRADE_T = TINYINT(3, unsigned=True)
def upgrade():
""" Upgrade 'Yes', 'No', 'Abstain' and 'ActiveTUs' to unsigned INTEGER. """
"""Upgrade 'Yes', 'No', 'Abstain' and 'ActiveTUs' to unsigned INTEGER."""
op.alter_column("TU_VoteInfo", "Yes", type_=UPGRADE_T)
op.alter_column("TU_VoteInfo", "No", type_=UPGRADE_T)
op.alter_column("TU_VoteInfo", "Abstain", type_=UPGRADE_T)
......
......@@ -8,20 +8,19 @@ Create Date: 2022-02-18 12:47:05.322766
from datetime import datetime
import sqlalchemy as sa
from alembic import op
from aurweb import db
from aurweb.models import PackageVote
# revision identifiers, used by Alembic.
revision = 'd64e5571bc8d'
down_revision = 'be7adae47ac3'
revision = "d64e5571bc8d"
down_revision = "be7adae47ac3"
branch_labels = None
depends_on = None
table = PackageVote.__tablename__
column = 'VoteTS'
column = "VoteTS"
epoch = datetime(1970, 1, 1)
......
......@@ -6,31 +6,32 @@ Create Date: 2020-06-08 10:04:13.898617
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.engine.reflection import Inspector
# revision identifiers, used by Alembic.
revision = 'ef39fcd6e1cd'
down_revision = 'f47cad5d6d03'
revision = "ef39fcd6e1cd"
down_revision = "f47cad5d6d03"
branch_labels = None
depends_on = None
def table_has_column(table, column_name):
for element in Inspector.from_engine(op.get_bind()).get_columns(table):
if element.get('name') == column_name:
if element.get("name") == column_name:
return True
return False
def upgrade():
if not table_has_column('Users', 'SSOAccountID'):
op.add_column('Users', sa.Column('SSOAccountID', sa.String(length=255), nullable=True))
op.create_unique_constraint(None, 'Users', ['SSOAccountID'])
if not table_has_column("Users", "SSOAccountID"):
op.add_column(
"Users", sa.Column("SSOAccountID", sa.String(length=255), nullable=True)
)
op.create_unique_constraint(None, "Users", ["SSOAccountID"])
def downgrade():
if table_has_column('Users', 'SSOAccountID'):
op.drop_constraint('SSOAccountID', 'Users', type_='unique')
op.drop_column('Users', 'SSOAccountID')
if table_has_column("Users", "SSOAccountID"):
op.drop_constraint("SSOAccountID", "Users", type_="unique")
op.drop_column("Users", "SSOAccountID")
......@@ -5,7 +5,7 @@ Create Date: 2020-02-23 13:23:32.331396
"""
# revision identifiers, used by Alembic.
revision = 'f47cad5d6d03'
revision = "f47cad5d6d03"
down_revision = None
branch_labels = None
depends_on = None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment