Initial commit: InviteMe production redesign
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
"""Initial production schema
|
||||
|
||||
Revision ID: 5e84226bd650
|
||||
Revises:
|
||||
Create Date: 2026-08-31 10:22:33.543712
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5e84226bd650'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('smtp_settings',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('mail_server', sa.String(length=255), nullable=False),
|
||||
sa.Column('mail_port', sa.Integer(), nullable=False),
|
||||
sa.Column('mail_use_ssl', sa.Boolean(), nullable=False),
|
||||
sa.Column('mail_username', sa.String(length=255), nullable=False),
|
||||
sa.Column('mail_password', sa.String(length=1024), nullable=False),
|
||||
sa.Column('mail_default_sender', sa.String(length=255), nullable=True),
|
||||
sa.Column('use_local_outlook', sa.Boolean(), nullable=False),
|
||||
sa.Column('use_ews', sa.Boolean(), nullable=False),
|
||||
sa.Column('ews_url', sa.String(length=500), nullable=True),
|
||||
sa.Column('imap_server', sa.String(length=255), nullable=True),
|
||||
sa.Column('imap_port', sa.Integer(), nullable=False),
|
||||
sa.Column('imap_use_ssl', sa.Boolean(), nullable=False),
|
||||
sa.Column('imap_username', sa.String(length=255), nullable=True),
|
||||
sa.Column('imap_password', sa.String(length=1024), nullable=True),
|
||||
sa.Column('imap_folder', sa.String(length=255), nullable=True),
|
||||
sa.Column('imap_save_copy', sa.Boolean(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('username', sa.String(length=100), nullable=False),
|
||||
sa.Column('password_hash', sa.String(length=255), nullable=False),
|
||||
sa.Column('role', sa.String(length=20), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('session_version', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('username')
|
||||
)
|
||||
op.create_table('audit_logs',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('username', sa.String(length=100), nullable=True),
|
||||
sa.Column('action', sa.String(length=50), nullable=False),
|
||||
sa.Column('target_type', sa.String(length=50), nullable=True),
|
||||
sa.Column('target_id', sa.String(length=50), nullable=True),
|
||||
sa.Column('details', sa.Text(), nullable=True),
|
||||
sa.Column('ip_address', sa.String(length=45), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('events',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('event_date', sa.DateTime(), nullable=True),
|
||||
sa.Column('location', sa.String(length=255), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_by_id', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('ticket_title', sa.String(length=255), nullable=True),
|
||||
sa.Column('ticket_subtitle', sa.String(length=255), nullable=True),
|
||||
sa.Column('ticket_body_text', sa.Text(), nullable=True),
|
||||
sa.Column('ticket_background_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('ticket_text_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('ticket_accent_color', sa.String(length=7), nullable=True),
|
||||
sa.Column('ticket_show_qr', sa.Boolean(), nullable=False),
|
||||
sa.Column('ticket_show_photo', sa.Boolean(), nullable=False),
|
||||
sa.Column('ticket_layout', sa.String(length=20), nullable=True),
|
||||
sa.Column('logo_filename', sa.String(length=255), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('event_staff',
|
||||
sa.Column('event_id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['event_id'], ['events.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('event_id', 'user_id')
|
||||
)
|
||||
op.create_table('guests',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('event_id', sa.Integer(), nullable=False),
|
||||
sa.Column('department', sa.String(length=255), nullable=False),
|
||||
sa.Column('last_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('first_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('middle_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('full_name', sa.String(length=255), nullable=False),
|
||||
sa.Column('position', sa.String(length=255), nullable=True),
|
||||
sa.Column('email', sa.String(length=255), nullable=False),
|
||||
sa.Column('phone', sa.String(length=50), nullable=True),
|
||||
sa.Column('photo_filename', sa.String(length=255), nullable=True),
|
||||
sa.Column('token', sa.String(length=36), nullable=False),
|
||||
sa.Column('qr_filename', sa.String(length=255), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('invitation_sent', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['event_id'], ['events.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('token')
|
||||
)
|
||||
op.create_table('check_ins',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('guest_id', sa.Integer(), nullable=False),
|
||||
sa.Column('event_id', sa.Integer(), nullable=True),
|
||||
sa.Column('checked_in_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('device_info', sa.String(length=500), nullable=True),
|
||||
sa.ForeignKeyConstraint(['event_id'], ['events.id'], ),
|
||||
sa.ForeignKeyConstraint(['guest_id'], ['guests.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('check_ins')
|
||||
op.drop_table('guests')
|
||||
op.drop_table('event_staff')
|
||||
op.drop_table('events')
|
||||
op.drop_table('audit_logs')
|
||||
op.drop_table('users')
|
||||
op.drop_table('smtp_settings')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,102 @@
|
||||
"""Add delivery reliability and RSVP
|
||||
|
||||
Revision ID: 8c365be4d3a0
|
||||
Revises: 5e84226bd650
|
||||
Create Date: 2026-09-01 09:06:31.547215
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8c365be4d3a0'
|
||||
down_revision = '5e84226bd650'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('audit_logs', schema=None) as batch_op:
|
||||
batch_op.create_index('ix_audit_logs_action', ['action'], unique=False)
|
||||
batch_op.create_index('ix_audit_logs_created_at', ['created_at'], unique=False)
|
||||
batch_op.create_index('ix_audit_logs_username', ['username'], unique=False)
|
||||
|
||||
op.execute(sa.text(
|
||||
"DELETE FROM check_ins WHERE id NOT IN "
|
||||
"(SELECT MIN(id) FROM check_ins GROUP BY guest_id)"
|
||||
))
|
||||
with op.batch_alter_table('check_ins', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('checked_in_by_id', sa.Integer(), nullable=True))
|
||||
batch_op.create_index('ix_check_ins_event_time', ['event_id', 'checked_in_at'], unique=False)
|
||||
batch_op.create_unique_constraint('uq_check_ins_guest_id', ['guest_id'])
|
||||
batch_op.create_foreign_key('fk_check_ins_checked_in_by_id_users', 'users', ['checked_in_by_id'], ['id'])
|
||||
|
||||
with op.batch_alter_table('events', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('event_end_date', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('rsvp_enabled', sa.Boolean(), nullable=False, server_default=sa.true()))
|
||||
batch_op.add_column(sa.Column('rsvp_deadline', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('invitation_subject', sa.String(length=255), nullable=True))
|
||||
batch_op.add_column(sa.Column('invitation_message', sa.Text(), nullable=True))
|
||||
batch_op.create_index('ix_events_created_by_active', ['created_by_id', 'is_active'], unique=False)
|
||||
batch_op.create_index('ix_events_event_date', ['event_date'], unique=False)
|
||||
|
||||
with op.batch_alter_table('guests', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('invitation_status', sa.String(length=20), nullable=False, server_default='pending'))
|
||||
batch_op.add_column(sa.Column('invitation_attempts', sa.Integer(), nullable=False, server_default='0'))
|
||||
batch_op.add_column(sa.Column('invitation_last_error', sa.String(length=1000), nullable=True))
|
||||
batch_op.add_column(sa.Column('invitation_last_attempt_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('invitation_sent_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('rsvp_status', sa.String(length=20), nullable=False, server_default='pending'))
|
||||
batch_op.add_column(sa.Column('rsvp_responded_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('rsvp_comment', sa.String(length=1000), nullable=True))
|
||||
batch_op.add_column(sa.Column('dietary_requirements', sa.String(length=1000), nullable=True))
|
||||
batch_op.create_index('ix_guests_event_active', ['event_id', 'is_active'], unique=False)
|
||||
batch_op.create_index('ix_guests_event_email', ['event_id', 'email'], unique=False)
|
||||
batch_op.create_index('ix_guests_event_full_name', ['event_id', 'full_name'], unique=False)
|
||||
batch_op.create_index('ix_guests_event_rsvp', ['event_id', 'rsvp_status'], unique=False)
|
||||
|
||||
op.execute(sa.text("UPDATE guests SET invitation_status = 'sent' WHERE invitation_sent = true"))
|
||||
with op.batch_alter_table('events', schema=None) as batch_op:
|
||||
batch_op.alter_column('rsvp_enabled', server_default=None)
|
||||
with op.batch_alter_table('guests', schema=None) as batch_op:
|
||||
batch_op.alter_column('invitation_status', server_default=None)
|
||||
batch_op.alter_column('invitation_attempts', server_default=None)
|
||||
batch_op.alter_column('rsvp_status', server_default=None)
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('guests', schema=None) as batch_op:
|
||||
batch_op.drop_index('ix_guests_event_rsvp')
|
||||
batch_op.drop_index('ix_guests_event_full_name')
|
||||
batch_op.drop_index('ix_guests_event_email')
|
||||
batch_op.drop_index('ix_guests_event_active')
|
||||
batch_op.drop_column('dietary_requirements')
|
||||
batch_op.drop_column('rsvp_comment')
|
||||
batch_op.drop_column('rsvp_responded_at')
|
||||
batch_op.drop_column('rsvp_status')
|
||||
batch_op.drop_column('invitation_sent_at')
|
||||
batch_op.drop_column('invitation_last_attempt_at')
|
||||
batch_op.drop_column('invitation_last_error')
|
||||
batch_op.drop_column('invitation_attempts')
|
||||
batch_op.drop_column('invitation_status')
|
||||
|
||||
with op.batch_alter_table('events', schema=None) as batch_op:
|
||||
batch_op.drop_index('ix_events_event_date')
|
||||
batch_op.drop_index('ix_events_created_by_active')
|
||||
batch_op.drop_column('invitation_message')
|
||||
batch_op.drop_column('invitation_subject')
|
||||
batch_op.drop_column('rsvp_deadline')
|
||||
batch_op.drop_column('rsvp_enabled')
|
||||
batch_op.drop_column('event_end_date')
|
||||
|
||||
with op.batch_alter_table('check_ins', schema=None) as batch_op:
|
||||
batch_op.drop_constraint('fk_check_ins_checked_in_by_id_users', type_='foreignkey')
|
||||
batch_op.drop_constraint('uq_check_ins_guest_id', type_='unique')
|
||||
batch_op.drop_index('ix_check_ins_event_time')
|
||||
batch_op.drop_column('checked_in_by_id')
|
||||
|
||||
with op.batch_alter_table('audit_logs', schema=None) as batch_op:
|
||||
batch_op.drop_index('ix_audit_logs_username')
|
||||
batch_op.drop_index('ix_audit_logs_created_at')
|
||||
batch_op.drop_index('ix_audit_logs_action')
|
||||
Reference in New Issue
Block a user