Generate alembic migration scripts for new models.

Generate alembic migration scripts for new database models.

Change-Id: Ifed2bf405a620cf8201a28fe8400bc6b1a30b1e4
This commit is contained in:
Robert Putt 2017-11-30 21:10:42 +00:00
parent 1836ccbc6b
commit 630bacb57c
3 changed files with 112 additions and 8 deletions

View File

@ -0,0 +1,68 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Initial models
#
# Revision ID: 53784f13e35d
# Revises: fecb5e4a7be4
# Create Date: 2017-11-30 21:10:13.531156
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '53784f13e35d'
down_revision = 'fecb5e4a7be4'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('file',
sa.Column('file_id', sa.BIGINT(), nullable=False),
sa.Column('sha512_hash', sa.TEXT(), nullable=True),
sa.Column('sha256_hash', sa.TEXT(), nullable=True),
sa.Column('sha1_hash', sa.TEXT(), nullable=True),
sa.Column('md5_hash', sa.TEXT(), nullable=True),
sa.Column('crc32', sa.TEXT(), nullable=True),
sa.Column('size', sa.FLOAT(), nullable=True),
sa.Column('mime_type', sa.VARCHAR(length=40),
nullable=True),
sa.Column('submitted_by', sa.VARCHAR(length=120),
nullable=False),
sa.Column('status', sa.VARCHAR(length=20), nullable=False),
sa.Column('last_updated', sa.DATETIME(), nullable=False),
sa.Column('first_seen', sa.DATETIME(), nullable=False),
sa.PrimaryKeyConstraint('file_id')
)
op.create_table('lookup_request',
sa.Column('request_id', sa.BIGINT(), nullable=False),
sa.Column('requested_at', sa.DATETIME(), nullable=False),
sa.Column('requestor', sa.VARCHAR(length=120),
nullable=False),
sa.Column('file_id', sa.BIGINT(), nullable=True),
sa.Column('lookup_hash', sa.TEXT(), nullable=False),
sa.Column('result', sa.VARCHAR(length=20), nullable=False),
sa.ForeignKeyConstraint(['file_id'], ['file.file_id'], ),
sa.PrimaryKeyConstraint('request_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('lookup_request')
op.drop_table('file')
# ### end Alembic commands ###

View File

@ -0,0 +1,36 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Blank initial database
#
# Revision ID: fecb5e4a7be4
# Revises:
# Create Date: 2017-11-30 21:01:52.006085
# revision identifiers, used by Alembic.
revision = 'fecb5e4a7be4'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###

View File

@ -1,15 +1,15 @@
[DEFAULT]
[keystone_authtoken]
identity_uri =
auth_uri =
admin_tenant_name =
admin_user =
admin_password =
auth_version =
auth_protocol =
identity_uri =
auth_uri =
admin_tenant_name =
admin_user =
admin_password =
auth_version =
auth_protocol =
delay_auth_decision = True
[sqlalchemy]
database_uri = sqlite:////tmp/nemesis.db
database_uri = sqlite:////tmp/nemesis.db
echo = true