aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-07-02 20:38:06 +0200
committerDaniel Schadt <kingdread@gmx.de>2022-07-02 20:38:06 +0200
commit1da9867007a49b5e8749daf96e0f4465a2fc4bd5 (patch)
tree968c67b41e3da30696a2db6ce04d769f16e50fac
parent98acce88c71a437bda17e80d463e6b1a1095f136 (diff)
downloadfietsboek-1da9867007a49b5e8749daf96e0f4465a2fc4bd5.tar.gz
fietsboek-1da9867007a49b5e8749daf96e0f4465a2fc4bd5.tar.bz2
fietsboek-1da9867007a49b5e8749daf96e0f4465a2fc4bd5.zip
generate proper alembic revision
-rw-r--r--fietsboek/alembic/versions/20220626_16ad57eec8bb.py33
-rw-r--r--fietsboek/alembic/versions/20220702_1b4b1c179e5a.py147
-rw-r--r--fietsboek/models/user.py1
3 files changed, 147 insertions, 34 deletions
diff --git a/fietsboek/alembic/versions/20220626_16ad57eec8bb.py b/fietsboek/alembic/versions/20220626_16ad57eec8bb.py
deleted file mode 100644
index d10c543..0000000
--- a/fietsboek/alembic/versions/20220626_16ad57eec8bb.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""empty message
-
-Revision ID: 16ad57eec8bb
-Revises:
-Create Date: 2022-06-26 21:40:37.366364
-
-"""
-from alembic import op
-import sqlalchemy as sa
-
-
-# revision identifiers, used by Alembic.
-revision = '16ad57eec8bb'
-down_revision = None
-branch_labels = None
-depends_on = None
-
-def upgrade():
- # ### commands auto generated by Alembic - please adjust! ###
- op.create_table('models',
- sa.Column('id', sa.Integer(), nullable=False),
- sa.Column('name', sa.Text(), nullable=True),
- sa.Column('value', sa.Integer(), nullable=True),
- sa.PrimaryKeyConstraint('id', name=op.f('pk_models'))
- )
- op.create_index('my_index', 'models', ['name'], unique=True, mysql_length=255)
- # ### end Alembic commands ###
-
-def downgrade():
- # ### commands auto generated by Alembic - please adjust! ###
- op.drop_index('my_index', table_name='models', mysql_length=255)
- op.drop_table('models')
- # ### end Alembic commands ###
diff --git a/fietsboek/alembic/versions/20220702_1b4b1c179e5a.py b/fietsboek/alembic/versions/20220702_1b4b1c179e5a.py
new file mode 100644
index 0000000..af6d73a
--- /dev/null
+++ b/fietsboek/alembic/versions/20220702_1b4b1c179e5a.py
@@ -0,0 +1,147 @@
+"""Initial database layout
+
+Revision ID: 1b4b1c179e5a
+Revises:
+Create Date: 2022-07-02 20:36:23.501403
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '1b4b1c179e5a'
+down_revision = None
+branch_labels = None
+depends_on = None
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('badges',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('title', sa.Text(), nullable=True),
+ sa.Column('image', sa.LargeBinary(), nullable=True),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_badges'))
+ )
+ op.create_table('users',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('name', sa.Text(), nullable=True),
+ sa.Column('password', sa.LargeBinary(), nullable=True),
+ sa.Column('salt', sa.LargeBinary(), nullable=True),
+ sa.Column('email', sa.Text(), nullable=True),
+ sa.Column('is_admin', sa.Boolean(), nullable=True),
+ sa.Column('is_verified', sa.Boolean(), nullable=True),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_users'))
+ )
+ op.create_index('idx_users_email', 'users', ['email'], unique=True)
+ op.create_table('friend_requests',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('sender_id', sa.Integer(), nullable=True),
+ sa.Column('recipient_id', sa.Integer(), nullable=True),
+ sa.Column('date', sa.DateTime(), nullable=True),
+ sa.ForeignKeyConstraint(['recipient_id'], ['users.id'], name=op.f('fk_friend_requests_recipient_id_users')),
+ sa.ForeignKeyConstraint(['sender_id'], ['users.id'], name=op.f('fk_friend_requests_sender_id_users')),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_friend_requests')),
+ sa.UniqueConstraint('sender_id', 'recipient_id', name=op.f('uq_friend_requests_sender_id'))
+ )
+ op.create_table('friends_assoc',
+ sa.Column('user_1_id', sa.Integer(), nullable=False),
+ sa.Column('user_2_id', sa.Integer(), nullable=False),
+ sa.ForeignKeyConstraint(['user_1_id'], ['users.id'], name=op.f('fk_friends_assoc_user_1_id_users')),
+ sa.ForeignKeyConstraint(['user_2_id'], ['users.id'], name=op.f('fk_friends_assoc_user_2_id_users')),
+ sa.PrimaryKeyConstraint('user_1_id', 'user_2_id', name=op.f('pk_friends_assoc'))
+ )
+ op.create_table('tokens',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('user_id', sa.Integer(), nullable=True),
+ sa.Column('uuid', sa.Text(), nullable=True),
+ sa.Column('token_type', sa.Enum('VERIFY_EMAIL', 'RESET_PASSWORD', name='tokentype'), nullable=True),
+ sa.Column('date', sa.DateTime(), nullable=True),
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_tokens_user_id_users')),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_tokens'))
+ )
+ op.create_index('idx_token_uuid', 'tokens', ['uuid'], unique=True)
+ op.create_table('tracks',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('owner_id', sa.Integer(), nullable=True),
+ sa.Column('title', sa.Text(), nullable=True),
+ sa.Column('description', sa.Text(), nullable=True),
+ sa.Column('date', sa.DateTime(), nullable=True),
+ sa.Column('gpx', sa.LargeBinary(), nullable=True),
+ sa.Column('visibility', sa.Enum('PRIVATE', 'FRIENDS', 'FRIENDS_TAGGED', 'LOGGED_IN', 'PUBLIC', name='visibility'), nullable=True),
+ sa.Column('link_secret', sa.Text(), nullable=True),
+ sa.ForeignKeyConstraint(['owner_id'], ['users.id'], name=op.f('fk_tracks_owner_id_users')),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_tracks'))
+ )
+ op.create_table('uploads',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('uploaded_at', sa.DateTime(), nullable=True),
+ sa.Column('owner_id', sa.Integer(), nullable=True),
+ sa.Column('gpx', sa.LargeBinary(), nullable=True),
+ sa.ForeignKeyConstraint(['owner_id'], ['users.id'], name=op.f('fk_uploads_owner_id_users')),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_uploads'))
+ )
+ op.create_table('comments',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('author_id', sa.Integer(), nullable=True),
+ sa.Column('track_id', sa.Integer(), nullable=True),
+ sa.Column('date', sa.DateTime(), nullable=True),
+ sa.Column('title', sa.Text(), nullable=True),
+ sa.Column('text', sa.Text(), nullable=True),
+ sa.ForeignKeyConstraint(['author_id'], ['users.id'], name=op.f('fk_comments_author_id_users')),
+ sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], name=op.f('fk_comments_track_id_tracks')),
+ sa.PrimaryKeyConstraint('id', name=op.f('pk_comments'))
+ )
+ op.create_table('tags',
+ sa.Column('track_id', sa.Integer(), nullable=False),
+ sa.Column('tag', sa.Text(), nullable=False),
+ sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], name=op.f('fk_tags_track_id_tracks')),
+ sa.PrimaryKeyConstraint('track_id', 'tag', name=op.f('pk_tags'))
+ )
+ op.create_table('track_badge_assoc',
+ sa.Column('track_id', sa.Integer(), nullable=False),
+ sa.Column('badge_id', sa.Integer(), nullable=False),
+ sa.ForeignKeyConstraint(['badge_id'], ['badges.id'], name=op.f('fk_track_badge_assoc_badge_id_badges')),
+ sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], name=op.f('fk_track_badge_assoc_track_id_tracks')),
+ sa.PrimaryKeyConstraint('track_id', 'badge_id', name=op.f('pk_track_badge_assoc'))
+ )
+ op.create_table('track_cache',
+ sa.Column('track_id', sa.Integer(), nullable=False),
+ sa.Column('length', sa.Float(), nullable=True),
+ sa.Column('uphill', sa.Float(), nullable=True),
+ sa.Column('downhill', sa.Float(), nullable=True),
+ sa.Column('moving_time', sa.Float(), nullable=True),
+ sa.Column('stopped_time', sa.Float(), nullable=True),
+ sa.Column('max_speed', sa.Float(), nullable=True),
+ sa.Column('avg_speed', sa.Float(), nullable=True),
+ sa.Column('start_time', sa.DateTime(), nullable=True),
+ sa.Column('end_time', sa.DateTime(), nullable=True),
+ sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], name=op.f('fk_track_cache_track_id_tracks')),
+ sa.PrimaryKeyConstraint('track_id', name=op.f('pk_track_cache'))
+ )
+ op.create_table('track_people_assoc',
+ sa.Column('track_id', sa.Integer(), nullable=False),
+ sa.Column('user_id', sa.Integer(), nullable=False),
+ sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], name=op.f('fk_track_people_assoc_track_id_tracks')),
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_track_people_assoc_user_id_users')),
+ sa.PrimaryKeyConstraint('track_id', 'user_id', name=op.f('pk_track_people_assoc'))
+ )
+ # ### end Alembic commands ###
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_table('track_people_assoc')
+ op.drop_table('track_cache')
+ op.drop_table('track_badge_assoc')
+ op.drop_table('tags')
+ op.drop_table('comments')
+ op.drop_table('uploads')
+ op.drop_table('tracks')
+ op.drop_index('idx_token_uuid', table_name='tokens')
+ op.drop_table('tokens')
+ op.drop_table('friends_assoc')
+ op.drop_table('friend_requests')
+ op.drop_index('idx_users_email', table_name='users')
+ op.drop_table('users')
+ op.drop_table('badges')
+ # ### end Alembic commands ###
diff --git a/fietsboek/models/user.py b/fietsboek/models/user.py
index 75707e2..d70c99e 100644
--- a/fietsboek/models/user.py
+++ b/fietsboek/models/user.py
@@ -208,7 +208,6 @@ class User(Base):
object_session(self).execute(stmt)
-Index('idx_users_name', User.name, unique=True)
Index('idx_users_email', User.email, unique=True)