Add question ownership and sharing
Questions now have a created_by field linking to the user who created them. Users only see questions they own or that have been shared with them. Includes share dialog, user search, bulk sharing, and export/import respects ownership. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Add turn tracking fields to Game model
|
||||
|
||||
Revision ID: 2937635f309a
|
||||
Revises: 90b81e097444
|
||||
Create Date: 2026-01-13 08:56:51.426585
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2937635f309a'
|
||||
down_revision = '90b81e097444'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('games', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('current_turn_team_id', sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column('turn_order', sa.JSON(), nullable=True))
|
||||
batch_op.add_column(sa.Column('is_steal_mode', sa.Boolean(), nullable=True))
|
||||
batch_op.create_foreign_key('fk_games_current_turn_team', 'teams', ['current_turn_team_id'], ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('games', schema=None) as batch_op:
|
||||
batch_op.drop_constraint('fk_games_current_turn_team', type_='foreignkey')
|
||||
batch_op.drop_column('is_steal_mode')
|
||||
batch_op.drop_column('turn_order')
|
||||
batch_op.drop_column('current_turn_team_id')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,59 @@
|
||||
"""Add question ownership and sharing
|
||||
|
||||
Revision ID: 9a119272b516
|
||||
Revises: d2113a61fa42
|
||||
Create Date: 2026-04-03 09:32:53.890510
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import sqlite
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9a119272b516'
|
||||
down_revision = 'd2113a61fa42'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('question_shares',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('question_id', sa.Integer(), nullable=False),
|
||||
sa.Column('shared_with_user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('shared_by_user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
|
||||
sa.ForeignKeyConstraint(['shared_by_user_id'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['shared_with_user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('question_id', 'shared_with_user_id', name='unique_question_share')
|
||||
)
|
||||
with op.batch_alter_table('games', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('completed_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('winners', sa.JSON(), nullable=True))
|
||||
batch_op.drop_column('turn_order')
|
||||
batch_op.drop_column('is_steal_mode')
|
||||
|
||||
with op.batch_alter_table('questions', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('created_by', sa.Integer(), nullable=True))
|
||||
batch_op.create_foreign_key('fk_questions_created_by', 'users', ['created_by'], ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('questions', schema=None) as batch_op:
|
||||
batch_op.drop_constraint('fk_questions_created_by', type_='foreignkey')
|
||||
batch_op.drop_column('created_by')
|
||||
|
||||
with op.batch_alter_table('games', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('is_steal_mode', sa.BOOLEAN(), nullable=True))
|
||||
batch_op.add_column(sa.Column('turn_order', sqlite.JSON(), nullable=True))
|
||||
batch_op.drop_column('winners')
|
||||
batch_op.drop_column('completed_at')
|
||||
|
||||
op.drop_table('question_shares')
|
||||
# ### end Alembic commands ###
|
||||
@@ -17,18 +17,10 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('games', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('current_turn_team_id', sa.Integer(), nullable=True))
|
||||
batch_op.create_foreign_key('fk_games_current_turn_team_id', 'teams', ['current_turn_team_id'], ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
# No-op: columns already added by 2937635f309a
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('games', schema=None) as batch_op:
|
||||
batch_op.drop_constraint('fk_games_current_turn_team_id', type_='foreignkey')
|
||||
batch_op.drop_column('current_turn_team_id')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
# No-op: columns managed by 2937635f309a
|
||||
pass
|
||||
|
||||
24
migrations/versions/d2113a61fa42_merge_heads.py
Normal file
24
migrations/versions/d2113a61fa42_merge_heads.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""Merge heads
|
||||
|
||||
Revision ID: d2113a61fa42
|
||||
Revises: 2937635f309a, a1b2c3d4e5f6
|
||||
Create Date: 2026-04-03 09:32:19.765953
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd2113a61fa42'
|
||||
down_revision = ('2937635f309a', 'a1b2c3d4e5f6')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
Reference in New Issue
Block a user