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

wip Fix #1281 As a shop owner I can assign managers to plan(s) #1303

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Merge 9083452d3a80 bb76d2149316

Revision ID: 535f7111e416
Revises: 9083452d3a80, bb76d2149316
Create Date: 2024-02-17 19:03:56.495742

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '535f7111e416'
down_revision = ('9083452d3a80', 'bb76d2149316')
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
36 changes: 36 additions & 0 deletions migrations/versions/9083452d3a80_add_catagory_user_associations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""add catagory_user_associations

Revision ID: 9083452d3a80
Revises: 48074e6225c6
Create Date: 2024-02-16 21:38:11.302398

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "9083452d3a80"
down_revision = "48074e6225c6"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"catagory_user_associations",
sa.Column("category_uuid", sa.String(), nullable=True),
sa.Column("user_id", sa.String(), nullable=True),
sa.ForeignKeyConstraint(
["category_uuid"],
["category.uuid"],
),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
)


def downgrade():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""primary keys association_table_plan_to_users

Revision ID: ac23e0d75b27
Revises: ba57f5aeba5f
Create Date: 2024-02-24 16:15:56.898449

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import MetaData, Table, Column, Integer, String


# revision identifiers, used by Alembic.
revision = "ac23e0d75b27"
down_revision = "ba57f5aeba5f"
branch_labels = None
depends_on = None


def upgrade():
meta = MetaData()
some_table = Table(
"plan_user_associations",
meta,
Column("plan_uuid", String, nullable=False),
Column("user_id", Integer, nullable=False),
sa.ForeignKeyConstraint(
["plan_uuid"],
["plan.uuid"],
),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("plan_uuid", "user_id"),
)

with op.batch_alter_table(
"plan_user_associations", copy_from=some_table
) as batch_op:
batch_op.create_primary_key(
"pk_plan_user_association", ["plan_uuid", "user_id"]
)


def downgrade():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Merge 535f7111e416 d80effffd83d

Revision ID: ba57f5aeba5f
Revises: 535f7111e416, d80effffd83d
Create Date: 2024-02-19 20:09:25.499959

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ba57f5aeba5f'
down_revision = ('535f7111e416', 'd80effffd83d')
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""add parent_plan_revision_uuid to plan

Revision ID: bb76d2149316
Revises: 48074e6225c6
Create Date: 2024-02-16 23:22:02.230866

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "bb76d2149316"
down_revision = "48074e6225c6"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("plan", schema=None) as batch_op:
batch_op.add_column(
sa.Column("parent_plan_revision_uuid", sa.String(), nullable=True)
)


def downgrade():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""feature_can_assign_users_to_plans settings

Revision ID: c4c7bbe1acdc
Revises: ac23e0d75b27
Create Date: 2024-02-26 09:06:42.508631

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "c4c7bbe1acdc"
down_revision = "ac23e0d75b27"
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table("setting", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"feature_can_assign_users_to_plans",
sa.Boolean(),
nullable=True,
default=False,
)
)


def downgrade():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""add association_table_plan_to_users

Revision ID: d80effffd83d
Revises: 48074e6225c6
Create Date: 2024-02-12 12:24:44.482877

Why?

Some shop owners want/need to assign managers (users) to
plans. For example large clubs or membership organisations which
assign a 'manager' to one or more plans.

The plan_user_associations table begins to make possible the
assignment of Users to Plans. Recall that Users (see class User
in models.py) is a shop owner (admin) which may login to the
Subscribie application.

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "d80effffd83d"
down_revision = "48074e6225c6"
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
"plan_user_associations",
sa.Column("plan_uuid", sa.String(), nullable=True),
sa.Column("user_id", sa.String(), nullable=True),
sa.ForeignKeyConstraint(
["plan_uuid"],
["plan.uuid"],
),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
)


def downgrade():
pass
Loading
Loading