Spaces:
Sleeping
Sleeping
restore non-secret backend/alembic/versions/ffc5eb832d0d_add_smart_home_credentials.py
Browse files
backend/alembic/versions/ffc5eb832d0d_add_smart_home_credentials.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add smart home credentials
|
| 2 |
+
|
| 3 |
+
Revision ID: ffc5eb832d0d
|
| 4 |
+
Revises: aa093d5ca52c
|
| 5 |
+
Create Date: 2026-02-20 19:15:00.000000
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from alembic import op
|
| 9 |
+
import sqlalchemy as sa
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# revision identifiers, used by Alembic.
|
| 13 |
+
revision = 'ffc5eb832d0d'
|
| 14 |
+
down_revision = 'aa093d5ca52c'
|
| 15 |
+
branch_labels = None
|
| 16 |
+
depends_on = None
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def upgrade():
|
| 20 |
+
# ### HueBridge table
|
| 21 |
+
op.create_table(
|
| 22 |
+
'hue_bridges',
|
| 23 |
+
sa.Column('id', sa.Integer(), nullable=False),
|
| 24 |
+
sa.Column('user_id', sa.String(), nullable=False),
|
| 25 |
+
sa.Column('bridge_ip', sa.String(), nullable=False),
|
| 26 |
+
sa.Column('bridge_id', sa.String(), nullable=True),
|
| 27 |
+
sa.Column('name', sa.String(), nullable=True),
|
| 28 |
+
sa.Column('api_key', sa.String(), nullable=False),
|
| 29 |
+
sa.Column('last_connected_at', sa.DateTime(timezone=True), nullable=True),
|
| 30 |
+
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
| 31 |
+
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
| 32 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
| 33 |
+
sa.PrimaryKeyConstraint('id')
|
| 34 |
+
)
|
| 35 |
+
op.create_index(op.f('ix_hue_bridges_user_id'), 'hue_bridges', ['user_id'], unique=False)
|
| 36 |
+
|
| 37 |
+
# ### HomeAssistantConnection table
|
| 38 |
+
op.create_table(
|
| 39 |
+
'home_assistant_connections',
|
| 40 |
+
sa.Column('id', sa.Integer(), nullable=False),
|
| 41 |
+
sa.Column('user_id', sa.String(), nullable=False),
|
| 42 |
+
sa.Column('url', sa.String(), nullable=False),
|
| 43 |
+
sa.Column('name', sa.String(), nullable=True),
|
| 44 |
+
sa.Column('token', sa.String(), nullable=False),
|
| 45 |
+
sa.Column('last_connected_at', sa.DateTime(timezone=True), nullable=True),
|
| 46 |
+
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
| 47 |
+
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
| 48 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
| 49 |
+
sa.PrimaryKeyConstraint('id')
|
| 50 |
+
)
|
| 51 |
+
op.create_index(op.f('ix_home_assistant_connections_user_id'), 'home_assistant_connections', ['user_id'], unique=False)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def downgrade():
|
| 55 |
+
# ### Downgrade for HomeAssistantConnection
|
| 56 |
+
op.drop_index(op.f('ix_home_assistant_connections_user_id'), table_name='home_assistant_connections')
|
| 57 |
+
op.drop_table('home_assistant_connections')
|
| 58 |
+
|
| 59 |
+
# ### Downgrade for HueBridge
|
| 60 |
+
op.drop_index(op.f('ix_hue_bridges_user_id'), table_name='hue_bridges')
|
| 61 |
+
op.drop_table('hue_bridges')
|