aboutsummaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-09-21 21:33:40 -0400
committerCara Salter <cara@devcara.com>2022-09-21 21:33:40 -0400
commitf9b99ce66f56995a29709e9bf24750dab9430767 (patch)
tree3624255932ab500bcfa3043932acd31b23fe86b3 /migrations
parentb1ffd5220866dc9479fa284dfb2f0a0e111a6031 (diff)
downloadnccd-f9b99ce66f56995a29709e9bf24750dab9430767.tar.gz
nccd-f9b99ce66f56995a29709e9bf24750dab9430767.zip
bunch of features
registration, logging out, listing networks, user profiles
Diffstat (limited to 'migrations')
-rw-r--r--migrations/versions/44e4ecea108b_.py34
-rw-r--r--migrations/versions/49b3fa6a4173_add_manager_to_network.py30
-rw-r--r--migrations/versions/4acd1ace5eb6_.py44
-rw-r--r--migrations/versions/81173c1d4f0a_initial_migration.py45
-rw-r--r--migrations/versions/900a50c566c4_add_description_to_peers.py28
-rw-r--r--migrations/versions/afd561b2a827_add_admin_field.py28
-rw-r--r--migrations/versions/bc8f89f077d8_uniquify_network_subnet.py28
-rw-r--r--migrations/versions/e7963e59fb3c_.py30
8 files changed, 223 insertions, 44 deletions
diff --git a/migrations/versions/44e4ecea108b_.py b/migrations/versions/44e4ecea108b_.py
new file mode 100644
index 0000000..c225770
--- /dev/null
+++ b/migrations/versions/44e4ecea108b_.py
@@ -0,0 +1,34 @@
+"""empty message
+
+Revision ID: 44e4ecea108b
+Revises: e7963e59fb3c
+Create Date: 2022-09-21 12:33:11.723559
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '44e4ecea108b'
+down_revision = 'e7963e59fb3c'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('peer', sa.Column('owner_id', sa.String(), nullable=False))
+ op.drop_constraint('peer_owner_fkey', 'peer', type_='foreignkey')
+ op.create_foreign_key(None, 'peer', 'user', ['owner_id'], ['id'])
+ op.drop_column('peer', 'owner')
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('peer', sa.Column('owner', sa.VARCHAR(), autoincrement=False, nullable=False))
+ op.drop_constraint(None, 'peer', type_='foreignkey')
+ op.create_foreign_key('peer_owner_fkey', 'peer', 'user', ['owner'], ['id'])
+ op.drop_column('peer', 'owner_id')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/49b3fa6a4173_add_manager_to_network.py b/migrations/versions/49b3fa6a4173_add_manager_to_network.py
new file mode 100644
index 0000000..028c286
--- /dev/null
+++ b/migrations/versions/49b3fa6a4173_add_manager_to_network.py
@@ -0,0 +1,30 @@
+"""add manager to network
+
+Revision ID: 49b3fa6a4173
+Revises: 44e4ecea108b
+Create Date: 2022-09-21 12:37:26.465495
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '49b3fa6a4173'
+down_revision = '44e4ecea108b'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('network', sa.Column('manager_id', sa.String(), nullable=False))
+ op.create_foreign_key(None, 'network', 'user', ['manager_id'], ['id'])
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_constraint(None, 'network', type_='foreignkey')
+ op.drop_column('network', 'manager_id')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/4acd1ace5eb6_.py b/migrations/versions/4acd1ace5eb6_.py
new file mode 100644
index 0000000..da39eb2
--- /dev/null
+++ b/migrations/versions/4acd1ace5eb6_.py
@@ -0,0 +1,44 @@
+"""empty message
+
+Revision ID: 4acd1ace5eb6
+Revises: 946e687d2d42
+Create Date: 2022-09-21 10:20:39.896514
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = '4acd1ace5eb6'
+down_revision = '946e687d2d42'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('network',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('subnet', postgresql.CIDR(), nullable=False),
+ sa.Column('description', sa.String(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('peer',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('addr', postgresql.CIDR(), nullable=False),
+ sa.Column('public_key', sa.String(), nullable=False),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.drop_constraint('user_fs_uniquifier_key', 'user', type_='unique')
+ op.drop_column('user', 'fs_uniquifier')
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('user', sa.Column('fs_uniquifier', sa.VARCHAR(), autoincrement=False, nullable=False))
+ op.create_unique_constraint('user_fs_uniquifier_key', 'user', ['fs_uniquifier'])
+ op.drop_table('peer')
+ op.drop_table('network')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/81173c1d4f0a_initial_migration.py b/migrations/versions/81173c1d4f0a_initial_migration.py
index f96ff21..4345556 100644
--- a/migrations/versions/81173c1d4f0a_initial_migration.py
+++ b/migrations/versions/81173c1d4f0a_initial_migration.py
@@ -37,54 +37,11 @@ def upgrade():
sa.UniqueConstraint('email'),
sa.UniqueConstraint('fs_uniquifier')
)
- op.drop_table('enroll_requests')
- op.drop_table('_sqlx_migrations')
- op.drop_table('networks')
- op.drop_table('peers')
- op.drop_table('users')
- # ### end Alembic commands ###
+ # ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
- op.create_table('users',
- sa.Column('id', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('email', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('pref_name', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('pw_hash', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('last_login', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
- sa.PrimaryKeyConstraint('id', name='users_pkey'),
- postgresql_ignore_search_path=False
- )
- op.create_table('peers',
- sa.Column('id', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('addr', postgresql.CIDR(), autoincrement=False, nullable=False),
- sa.Column('public_key', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('owner', sa.TEXT(), autoincrement=False, nullable=False),
- sa.ForeignKeyConstraint(['owner'], ['users.id'], name='peers_owner_fkey'),
- sa.PrimaryKeyConstraint('id', name='peers_pkey')
- )
- op.create_table('networks',
- sa.Column('id', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('subnet', postgresql.CIDR(), autoincrement=False, nullable=False),
- sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True),
- sa.PrimaryKeyConstraint('id', name='networks_pkey')
- )
- op.create_table('_sqlx_migrations',
- sa.Column('version', sa.BIGINT(), autoincrement=False, nullable=False),
- sa.Column('description', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('installed_on', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
- sa.Column('success', sa.BOOLEAN(), autoincrement=False, nullable=False),
- sa.Column('checksum', postgresql.BYTEA(), autoincrement=False, nullable=False),
- sa.Column('execution_time', sa.BIGINT(), autoincrement=False, nullable=False),
- sa.PrimaryKeyConstraint('version', name='_sqlx_migrations_pkey')
- )
- op.create_table('enroll_requests',
- sa.Column('token', sa.TEXT(), autoincrement=False, nullable=False),
- sa.Column('expires', postgresql.TIMESTAMP(), server_default=sa.text("(CURRENT_TIMESTAMP + ((30)::double precision * '00:01:00'::interval))"), autoincrement=False, nullable=False),
- sa.Column('confirmed', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
- sa.PrimaryKeyConstraint('token', name='enroll_requests_pkey')
- )
op.drop_table('user')
op.drop_table('role')
# ### end Alembic commands ###
diff --git a/migrations/versions/900a50c566c4_add_description_to_peers.py b/migrations/versions/900a50c566c4_add_description_to_peers.py
new file mode 100644
index 0000000..de751bf
--- /dev/null
+++ b/migrations/versions/900a50c566c4_add_description_to_peers.py
@@ -0,0 +1,28 @@
+"""add description to peers
+
+Revision ID: 900a50c566c4
+Revises: 49b3fa6a4173
+Create Date: 2022-09-21 12:43:37.943280
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '900a50c566c4'
+down_revision = '49b3fa6a4173'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('peer', sa.Column('description', sa.String(), nullable=False))
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column('peer', 'description')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/afd561b2a827_add_admin_field.py b/migrations/versions/afd561b2a827_add_admin_field.py
new file mode 100644
index 0000000..da3552a
--- /dev/null
+++ b/migrations/versions/afd561b2a827_add_admin_field.py
@@ -0,0 +1,28 @@
+"""add admin field
+
+Revision ID: afd561b2a827
+Revises: bc8f89f077d8
+Create Date: 2022-09-21 16:10:37.422259
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'afd561b2a827'
+down_revision = 'bc8f89f077d8'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('user', sa.Column('is_admin', sa.Boolean(), nullable=False, server_default=str(False)))
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column('user', 'is_admin')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/bc8f89f077d8_uniquify_network_subnet.py b/migrations/versions/bc8f89f077d8_uniquify_network_subnet.py
new file mode 100644
index 0000000..e216a79
--- /dev/null
+++ b/migrations/versions/bc8f89f077d8_uniquify_network_subnet.py
@@ -0,0 +1,28 @@
+"""uniquify network subnet
+
+Revision ID: bc8f89f077d8
+Revises: 900a50c566c4
+Create Date: 2022-09-21 16:01:43.914719
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'bc8f89f077d8'
+down_revision = '900a50c566c4'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_unique_constraint(None, 'network', ['subnet'])
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_constraint(None, 'network', type_='unique')
+ # ### end Alembic commands ###
diff --git a/migrations/versions/e7963e59fb3c_.py b/migrations/versions/e7963e59fb3c_.py
new file mode 100644
index 0000000..dbed101
--- /dev/null
+++ b/migrations/versions/e7963e59fb3c_.py
@@ -0,0 +1,30 @@
+"""empty message
+
+Revision ID: e7963e59fb3c
+Revises: 4acd1ace5eb6
+Create Date: 2022-09-21 12:31:24.175307
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'e7963e59fb3c'
+down_revision = '4acd1ace5eb6'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('peer', sa.Column('owner', sa.String(), nullable=False))
+ op.create_foreign_key(None, 'peer', 'user', ['owner'], ['id'])
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_constraint(None, 'peer', type_='foreignkey')
+ op.drop_column('peer', 'owner')
+ # ### end Alembic commands ###