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 <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-09-11 18:07:54 -07:00
parent 03776c4663
commit b3853e01b8
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
6 changed files with 44 additions and 46 deletions

View file

@ -1,5 +1,3 @@
exclude: ^migrations/versions
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0 rev: v4.3.0

View file

@ -10,41 +10,41 @@ from alembic import op
import aurweb.config import aurweb.config
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '56e2ce8e2ffa' revision = "56e2ce8e2ffa"
down_revision = 'ef39fcd6e1cd' down_revision = "ef39fcd6e1cd"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
# Tables affected by charset/collate change # Tables affected by charset/collate change
tables = [ tables = [
('AccountTypes', 'utf8mb4', 'utf8mb4_general_ci'), ("AccountTypes", "utf8mb4", "utf8mb4_general_ci"),
('ApiRateLimit', 'utf8mb4', 'utf8mb4_general_ci'), ("ApiRateLimit", "utf8mb4", "utf8mb4_general_ci"),
('Bans', 'utf8mb4', 'utf8mb4_general_ci'), ("Bans", "utf8mb4", "utf8mb4_general_ci"),
('DependencyTypes', 'utf8mb4', 'utf8mb4_general_ci'), ("DependencyTypes", "utf8mb4", "utf8mb4_general_ci"),
('Groups', 'utf8mb4', 'utf8mb4_general_ci'), ("Groups", "utf8mb4", "utf8mb4_general_ci"),
('Licenses', 'utf8mb4', 'utf8mb4_general_ci'), ("Licenses", "utf8mb4", "utf8mb4_general_ci"),
('OfficialProviders', 'utf8mb4', 'utf8mb4_bin'), ("OfficialProviders", "utf8mb4", "utf8mb4_bin"),
('PackageBases', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageBases", "utf8mb4", "utf8mb4_general_ci"),
('PackageBlacklist', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageBlacklist", "utf8mb4", "utf8mb4_general_ci"),
('PackageComments', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageComments", "utf8mb4", "utf8mb4_general_ci"),
('PackageDepends', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageDepends", "utf8mb4", "utf8mb4_general_ci"),
('PackageKeywords', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageKeywords", "utf8mb4", "utf8mb4_general_ci"),
('PackageRelations', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageRelations", "utf8mb4", "utf8mb4_general_ci"),
('PackageRequests', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageRequests", "utf8mb4", "utf8mb4_general_ci"),
('PackageSources', 'utf8mb4', 'utf8mb4_general_ci'), ("PackageSources", "utf8mb4", "utf8mb4_general_ci"),
('Packages', 'utf8mb4', 'utf8mb4_general_ci'), ("Packages", "utf8mb4", "utf8mb4_general_ci"),
('RelationTypes', 'utf8mb4', 'utf8mb4_general_ci'), ("RelationTypes", "utf8mb4", "utf8mb4_general_ci"),
('RequestTypes', 'utf8mb4', 'utf8mb4_general_ci'), ("RequestTypes", "utf8mb4", "utf8mb4_general_ci"),
('SSHPubKeys', 'utf8mb4', 'utf8mb4_bin'), ("SSHPubKeys", "utf8mb4", "utf8mb4_bin"),
('Sessions', 'utf8mb4', 'utf8mb4_bin'), ("Sessions", "utf8mb4", "utf8mb4_bin"),
('TU_VoteInfo', 'utf8mb4', 'utf8mb4_general_ci'), ("TU_VoteInfo", "utf8mb4", "utf8mb4_general_ci"),
('Terms', 'utf8mb4', 'utf8mb4_general_ci'), ("Terms", "utf8mb4", "utf8mb4_general_ci"),
('Users', 'utf8mb4', 'utf8mb4_general_ci') ("Users", "utf8mb4", "utf8mb4_general_ci"),
] ]
# Indexes affected by charset/collate change # Indexes affected by charset/collate change
# Map of Unique Indexes key = index_name, value = [table_name, column1, column2] # 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. # Source charset/collation, before this migration is run.
src_charset = "utf8" src_charset = "utf8"

View file

@ -19,8 +19,8 @@ from alembic import op
from sqlalchemy.dialects.mysql import INTEGER, TINYINT from sqlalchemy.dialects.mysql import INTEGER, TINYINT
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = 'be7adae47ac3' revision = "be7adae47ac3"
down_revision = '56e2ce8e2ffa' down_revision = "56e2ce8e2ffa"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
@ -32,7 +32,7 @@ DOWNGRADE_T = TINYINT(3, unsigned=True)
def upgrade(): 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", "Yes", type_=UPGRADE_T)
op.alter_column("TU_VoteInfo", "No", type_=UPGRADE_T) op.alter_column("TU_VoteInfo", "No", type_=UPGRADE_T)
op.alter_column("TU_VoteInfo", "Abstain", type_=UPGRADE_T) op.alter_column("TU_VoteInfo", "Abstain", type_=UPGRADE_T)

View file

@ -8,20 +8,19 @@ Create Date: 2022-02-18 12:47:05.322766
from datetime import datetime from datetime import datetime
import sqlalchemy as sa import sqlalchemy as sa
from alembic import op from alembic import op
from aurweb import db from aurweb import db
from aurweb.models import PackageVote from aurweb.models import PackageVote
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = 'd64e5571bc8d' revision = "d64e5571bc8d"
down_revision = 'be7adae47ac3' down_revision = "be7adae47ac3"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
table = PackageVote.__tablename__ table = PackageVote.__tablename__
column = 'VoteTS' column = "VoteTS"
epoch = datetime(1970, 1, 1) epoch = datetime(1970, 1, 1)

View file

@ -6,31 +6,32 @@ Create Date: 2020-06-08 10:04:13.898617
""" """
import sqlalchemy as sa import sqlalchemy as sa
from alembic import op from alembic import op
from sqlalchemy.engine.reflection import Inspector from sqlalchemy.engine.reflection import Inspector
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = 'ef39fcd6e1cd' revision = "ef39fcd6e1cd"
down_revision = 'f47cad5d6d03' down_revision = "f47cad5d6d03"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
def table_has_column(table, column_name): def table_has_column(table, column_name):
for element in Inspector.from_engine(op.get_bind()).get_columns(table): 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 True
return False return False
def upgrade(): def upgrade():
if not table_has_column('Users', 'SSOAccountID'): if not table_has_column("Users", "SSOAccountID"):
op.add_column('Users', sa.Column('SSOAccountID', sa.String(length=255), nullable=True)) op.add_column(
op.create_unique_constraint(None, 'Users', ['SSOAccountID']) "Users", sa.Column("SSOAccountID", sa.String(length=255), nullable=True)
)
op.create_unique_constraint(None, "Users", ["SSOAccountID"])
def downgrade(): def downgrade():
if table_has_column('Users', 'SSOAccountID'): if table_has_column("Users", "SSOAccountID"):
op.drop_constraint('SSOAccountID', 'Users', type_='unique') op.drop_constraint("SSOAccountID", "Users", type_="unique")
op.drop_column('Users', 'SSOAccountID') op.drop_column("Users", "SSOAccountID")

View file

@ -5,7 +5,7 @@ Create Date: 2020-02-23 13:23:32.331396
""" """
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = 'f47cad5d6d03' revision = "f47cad5d6d03"
down_revision = None down_revision = None
branch_labels = None branch_labels = None
depends_on = None depends_on = None