mirror of
https://github.com/ferdzo/iotDashboard.git
synced 2026-04-05 17:16:26 +00:00
Added auth, environment brief, docker for db_migrations,frontend,backend.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
"""add users table
|
||||
|
||||
Revision ID: 7c71d43d53e3
|
||||
Revises: 4b84a36e13f5
|
||||
Create Date: 2025-12-15 21:24:36.718471+00:00
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7c71d43d53e3'
|
||||
down_revision: Union[str, Sequence[str], None] = '4b84a36e13f5'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Text(), nullable=False),
|
||||
sa.Column('username', sa.Text(), nullable=False),
|
||||
sa.Column('email', sa.Text(), nullable=False),
|
||||
sa.Column('password_hash', sa.Text(), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email'),
|
||||
sa.UniqueConstraint('username')
|
||||
)
|
||||
op.create_index('idx_users_email', 'users', ['email'], unique=False)
|
||||
op.create_index('idx_users_username', 'users', ['username'], unique=False)
|
||||
op.drop_index(op.f('dashboard_l_is_defa_033b71_idx'), table_name='dashboard_layouts')
|
||||
op.drop_index(op.f('dashboard_l_name_c36020_idx'), table_name='dashboard_layouts')
|
||||
op.drop_index(op.f('dashboard_layouts_name_349f3640_like'), table_name='dashboard_layouts', postgresql_ops={'name': 'varchar_pattern_ops'})
|
||||
op.drop_table('dashboard_layouts')
|
||||
op.drop_table('django_migrations')
|
||||
op.drop_table('iotDashboard_device')
|
||||
op.drop_constraint(op.f('telemetry_device_id_fkey'), 'telemetry', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'telemetry', 'devices', ['device_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'telemetry', type_='foreignkey')
|
||||
op.create_foreign_key(op.f('telemetry_device_id_fkey'), 'telemetry', 'devices', ['device_id'], ['id'], ondelete='CASCADE')
|
||||
op.create_table('iotDashboard_device',
|
||||
sa.Column('id', sa.BIGINT(), sa.Identity(always=False, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
|
||||
sa.Column('ip', sa.VARCHAR(length=20), autoincrement=False, nullable=False),
|
||||
sa.Column('protocol', sa.VARCHAR(length=20), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('iotDashboard_device_pkey'))
|
||||
)
|
||||
op.create_table('django_migrations',
|
||||
sa.Column('id', sa.BIGINT(), sa.Identity(always=False, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
|
||||
sa.Column('app', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column('applied', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('django_migrations_pkey'))
|
||||
)
|
||||
op.create_table('dashboard_layouts',
|
||||
sa.Column('id', sa.BIGINT(), sa.Identity(always=False, start=1, increment=1, minvalue=1, maxvalue=9223372036854775807, cycle=False, cache=1), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column('config', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=False),
|
||||
sa.Column('is_default', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('dashboard_layouts_pkey')),
|
||||
sa.UniqueConstraint('name', name=op.f('dashboard_layouts_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
|
||||
)
|
||||
op.create_index(op.f('dashboard_layouts_name_349f3640_like'), 'dashboard_layouts', ['name'], unique=False, postgresql_ops={'name': 'varchar_pattern_ops'})
|
||||
op.create_index(op.f('dashboard_l_name_c36020_idx'), 'dashboard_layouts', ['name'], unique=False)
|
||||
op.create_index(op.f('dashboard_l_is_defa_033b71_idx'), 'dashboard_layouts', ['is_default'], unique=False)
|
||||
op.drop_index('idx_users_username', table_name='users')
|
||||
op.drop_index('idx_users_email', table_name='users')
|
||||
op.drop_table('users')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,45 @@
|
||||
"""add cascade delete to telemetry foreign key
|
||||
|
||||
Revision ID: 1dfb0bb45f93
|
||||
Revises: 7c71d43d53e3
|
||||
Create Date: 2025-12-15 21:56:13.260281+00:00
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '1dfb0bb45f93'
|
||||
down_revision: Union[str, Sequence[str], None] = '7c71d43d53e3'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema - only update telemetry foreign key."""
|
||||
# Drop old foreign key constraint
|
||||
op.drop_constraint('telemetry_device_id_fkey', 'telemetry', type_='foreignkey')
|
||||
|
||||
# Add new foreign key constraint with CASCADE delete
|
||||
op.create_foreign_key(
|
||||
'telemetry_device_id_fkey',
|
||||
'telemetry', 'devices',
|
||||
['device_id'], ['id'],
|
||||
ondelete='CASCADE'
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema - revert foreign key change."""
|
||||
# Drop CASCADE foreign key
|
||||
op.drop_constraint('telemetry_device_id_fkey', 'telemetry', type_='foreignkey')
|
||||
|
||||
# Add back original foreign key without CASCADE
|
||||
op.create_foreign_key(
|
||||
'telemetry_device_id_fkey',
|
||||
'telemetry', 'devices',
|
||||
['device_id'], ['id']
|
||||
)
|
||||
Reference in New Issue
Block a user