-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
server/migrations/versions/07cfe7610f2d_organisation_units.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Organisation units | ||
Revision ID: 07cfe7610f2d | ||
Revises: 7b2c17d60467 | ||
Create Date: 2023-10-20 14:24:49.872836 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '07cfe7610f2d' | ||
down_revision = '7b2c17d60467' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table("units", | ||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False, autoincrement=True), | ||
sa.Column("name", sa.String(length=255), nullable=False), | ||
sa.Column("organisation_id", sa.Integer(), sa.ForeignKey("organisations.id", ondelete="cascade"), | ||
nullable=False), | ||
) | ||
op.create_table("collaboration_units", | ||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False, autoincrement=True), | ||
sa.Column("collaboration_id", sa.Integer(), | ||
sa.ForeignKey("collaborations.id", ondelete="cascade"), nullable=False), | ||
sa.Column("unit_id", sa.Integer(), | ||
sa.ForeignKey("units.id", ondelete="cascade"), nullable=False), | ||
) | ||
op.create_table("units_organisation_invitations", | ||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False, autoincrement=True), | ||
sa.Column("organisation_invitation_id", sa.Integer(), | ||
sa.ForeignKey("organisation_invitations.id", ondelete="cascade"), | ||
nullable=False), | ||
sa.Column("unit_id", sa.Integer(), | ||
sa.ForeignKey("units.id", ondelete="cascade"), nullable=False), | ||
) | ||
|
||
|
||
def downgrade(): | ||
pass |
25 changes: 25 additions & 0 deletions
25
server/migrations/versions/4f556306dfb2_organisation_units_unique_constraint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Organisation units unique constraint | ||
Revision ID: 4f556306dfb2 | ||
Revises: 07cfe7610f2d | ||
Create Date: 2023-10-20 14:34:58.137505 | ||
""" | ||
from alembic import op | ||
from sqlalchemy import text | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '4f556306dfb2' | ||
down_revision = '07cfe7610f2d' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
conn = op.get_bind() | ||
conn.execute(text( | ||
"ALTER TABLE units ADD UNIQUE INDEX organisation_units_unique(organisation_id, name)")) | ||
|
||
|
||
def downgrade(): | ||
pass |
37 changes: 37 additions & 0 deletions
37
server/migrations/versions/c83522c62564_organisation_units_part_of_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Organisation units part of OrganisationMembership and CollaborationRequest | ||
Revision ID: c83522c62564 | ||
Revises: 4f556306dfb2 | ||
Create Date: 2023-10-20 14:45:10.108920 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'c83522c62564' | ||
down_revision = '4f556306dfb2' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table("organisation_membership_units", | ||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False, autoincrement=True), | ||
sa.Column("organisation_membership_id", sa.Integer(), | ||
sa.ForeignKey("organisation_memberships.id", ondelete="cascade"), nullable=False), | ||
sa.Column("unit_id", sa.Integer(), | ||
sa.ForeignKey("units.id", ondelete="cascade"), nullable=False), | ||
) | ||
op.create_table("collaboration_requests_units", | ||
sa.Column("id", sa.Integer(), primary_key=True, nullable=False, autoincrement=True), | ||
sa.Column("collaboration_request_id", sa.Integer(), | ||
sa.ForeignKey("collaboration_requests.id", ondelete="cascade"), | ||
nullable=False), | ||
sa.Column("unit_id", sa.Integer(), | ||
sa.ForeignKey("units.id", ondelete="cascade"), nullable=False), | ||
) | ||
|
||
|
||
def downgrade(): | ||
pass |