Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Split Logs #41

Open
wants to merge 30 commits into
base: software-data-ii
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions alembic/versions/0de663bb9c13_only_month.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""Only Month

Revision ID: 0de663bb9c13
Revises: e0cad634525c
Create Date: 2024-11-18 13:50:09.959941

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "0de663bb9c13"
down_revision: Union[str, None] = "e0cad634525c"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("wikibase_log_observation")
with op.batch_alter_table("wikibase_log_observation_month") as batch_op:
batch_op.alter_column("first", existing_type=sa.BOOLEAN(), nullable=False)
batch_op.alter_column("wikibase_id", existing_type=sa.INTEGER(), nullable=False)
batch_op.alter_column("anything", existing_type=sa.BOOLEAN(), nullable=False)
batch_op.alter_column("date", existing_type=sa.DATETIME(), nullable=False)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("wikibase_log_observation_month") as batch_op:
batch_op.alter_column("date", existing_type=sa.DATETIME(), nullable=True)
batch_op.alter_column("anything", existing_type=sa.BOOLEAN(), nullable=True)
batch_op.alter_column("wikibase_id", existing_type=sa.INTEGER(), nullable=True)
batch_op.alter_column("first", existing_type=sa.BOOLEAN(), nullable=True)
op.create_table(
"wikibase_log_observation",
sa.Column("id", sa.INTEGER(), nullable=False),
sa.Column("wikibase_id", sa.INTEGER(), nullable=False),
sa.Column("anything", sa.BOOLEAN(), nullable=False),
sa.Column("date", sa.DATETIME(), nullable=False),
sa.Column("first_log_date", sa.DATETIME(), nullable=True),
sa.Column("last_log_date", sa.DATETIME(), nullable=True),
sa.Column("last_log_user_type", sa.VARCHAR(length=7), nullable=True),
sa.Column("first_month_id", sa.INTEGER(), nullable=True),
sa.Column("last_month_id", sa.INTEGER(), nullable=True),
sa.ForeignKeyConstraint(
["first_month_id"],
["wikibase_log_observation_month.id"],
name="first_month",
),
sa.ForeignKeyConstraint(
["last_month_id"], ["wikibase_log_observation_month.id"], name="last_month"
),
sa.ForeignKeyConstraint(
["wikibase_id"], ["wikibase.id"], name="observation_wikibase"
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
62 changes: 62 additions & 0 deletions alembic/versions/749172173f94_month_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Month Fields

Revision ID: 749172173f94
Revises: ced691eaf66e
Create Date: 2024-11-18 10:59:19.124446

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "749172173f94"
down_revision: Union[str, None] = "ced691eaf66e"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###

with op.batch_alter_table(
"wikibase_log_observation_month", recreate="always"
) as batch_op:
batch_op.add_column(
sa.Column("wikibase_id", sa.Integer(), nullable=True),
insert_before="first_log_date",
)
batch_op.add_column(
sa.Column("anything", sa.Boolean(), nullable=True),
insert_before="first_log_date",
)
batch_op.add_column(
sa.Column("date", sa.DateTime(timezone=True), nullable=True),
insert_before="first_log_date",
)
batch_op.add_column(
sa.Column(
"last_log_user_type",
sa.Enum("BOT", "MISSING", "USER", "NONE", name="wikibaseusertype"),
nullable=True,
),
insert_after="last_log_date",
)
batch_op.create_foreign_key(
"observation_wikibase", "wikibase", ["wikibase_id"], ["id"]
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("wikibase_log_observation_month") as batch_op:
batch_op.drop_constraint("observation_wikibase", type_="foreignkey")
batch_op.drop_column("last_log_user_type")
batch_op.drop_column("date")
batch_op.drop_column("anything")
batch_op.drop_column("wikibase_id")
# ### end Alembic commands ###
42 changes: 42 additions & 0 deletions alembic/versions/d6c7d96ba079_month_optional_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Month Optional Fields

Revision ID: d6c7d96ba079
Revises: 749172173f94
Create Date: 2024-11-18 13:18:58.190822

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "d6c7d96ba079"
down_revision: Union[str, None] = "749172173f94"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table(
"wikibase_log_observation_month", recreate="always"
) as batch_op:
batch_op.add_column(
sa.Column("first", sa.Boolean(), nullable=True),
insert_before="first_log_date",
)
batch_op.alter_column("log_count", existing_type=sa.INTEGER(), nullable=True)
batch_op.alter_column("user_count", existing_type=sa.INTEGER(), nullable=True)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("wikibase_log_observation_month") as batch_op:
batch_op.alter_column("user_count", existing_type=sa.INTEGER(), nullable=False)
batch_op.alter_column("log_count", existing_type=sa.INTEGER(), nullable=False)
batch_op.drop_column("first")
# ### end Alembic commands ###
Loading
Loading