File tree 2 files changed +51
-0
lines changed
packages/postgres-database/src/simcore_postgres_database 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 3
3
from ._common import column_created_datetime , column_modified_datetime
4
4
from .base import metadata
5
5
from .projects import projects
6
+ from .users import users
6
7
7
8
projects_comments = sa .Table (
8
9
"projects_comments" ,
25
26
onupdate = "CASCADE" ,
26
27
),
27
28
index = True ,
29
+ nullable = False ,
28
30
doc = "project reference for this table" ,
29
31
),
32
+ # NOTE: if the user gets deleted, it sets to null which should be interpreted as "unknown" user
30
33
sa .Column (
31
34
"user_id" ,
32
35
sa .BigInteger ,
36
+ sa .ForeignKey (
37
+ users .c .id ,
38
+ name = "fk_projects_comments_user_id" ,
39
+ ondelete = "SET NULL" ,
40
+ ),
33
41
doc = "user who created the comment" ,
42
+ nullable = True ,
34
43
),
35
44
sa .Column (
36
45
"contents" ,
You can’t perform that action at this time.
0 commit comments