File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
packages/postgres-database/src/simcore_postgres_database Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ """project comments minor improvements
2+
3+ Revision ID: 52cf00912ad9
4+ Revises: af5de00bf4cf
5+ Create Date: 2023-06-21 13:05:19.531115+00:00
6+
7+ """
8+ import sqlalchemy as sa
9+ from alembic import op
10+
11+ # revision identifiers, used by Alembic.
12+ revision = "52cf00912ad9"
13+ down_revision = "af5de00bf4cf"
14+ branch_labels = None
15+ depends_on = None
16+
17+
18+ def upgrade ():
19+ # ### commands auto generated by Alembic - please adjust! ###
20+ op .alter_column (
21+ "projects_comments" , "user_id" , existing_type = sa .BIGINT (), nullable = True
22+ )
23+ op .create_foreign_key (
24+ "fk_projects_comments_user_id" ,
25+ "projects_comments" ,
26+ "users" ,
27+ ["user_id" ],
28+ ["id" ],
29+ ondelete = "SET NULL" ,
30+ )
31+ # ### end Alembic commands ###
32+
33+
34+ def downgrade ():
35+ # ### commands auto generated by Alembic - please adjust! ###
36+ op .drop_constraint (
37+ "fk_projects_comments_user_id" , "projects_comments" , type_ = "foreignkey"
38+ )
39+ op .alter_column (
40+ "projects_comments" , "user_id" , existing_type = sa .BIGINT (), nullable = False
41+ )
42+ # ### end Alembic commands ###
Original file line number Diff line number Diff line change 33from ._common import column_created_datetime , column_modified_datetime
44from .base import metadata
55from .projects import projects
6+ from .users import users
67
78projects_comments = sa .Table (
89 "projects_comments" ,
2526 onupdate = "CASCADE" ,
2627 ),
2728 index = True ,
29+ nullable = False ,
2830 doc = "project reference for this table" ,
2931 ),
32+ # NOTE: if the user gets deleted, it sets to null which should be interpreted as "unknown" user
3033 sa .Column (
3134 "user_id" ,
3235 sa .BigInteger ,
36+ sa .ForeignKey (
37+ users .c .id ,
38+ name = "fk_projects_comments_user_id" ,
39+ ondelete = "SET NULL" ,
40+ ),
3341 doc = "user who created the comment" ,
42+ nullable = True ,
3443 ),
3544 sa .Column (
3645 "contents" ,
You can’t perform that action at this time.
0 commit comments