From 630bacb57c3353006348a64e36dc85b3ccba0f4a Mon Sep 17 00:00:00 2001 From: Robert Putt Date: Thu, 30 Nov 2017 21:10:42 +0000 Subject: [PATCH] Generate alembic migration scripts for new models. Generate alembic migration scripts for new database models. Change-Id: Ifed2bf405a620cf8201a28fe8400bc6b1a30b1e4 --- .../versions/53784f13e35d_initial_models.py | 68 +++++++++++++++++++ .../fecb5e4a7be4_blank_initial_database.py | 36 ++++++++++ nemesis.conf.sample | 16 ++--- 3 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 alembic/versions/53784f13e35d_initial_models.py create mode 100644 alembic/versions/fecb5e4a7be4_blank_initial_database.py diff --git a/alembic/versions/53784f13e35d_initial_models.py b/alembic/versions/53784f13e35d_initial_models.py new file mode 100644 index 0000000..5ace4d9 --- /dev/null +++ b/alembic/versions/53784f13e35d_initial_models.py @@ -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 ### diff --git a/alembic/versions/fecb5e4a7be4_blank_initial_database.py b/alembic/versions/fecb5e4a7be4_blank_initial_database.py new file mode 100644 index 0000000..e94b7e8 --- /dev/null +++ b/alembic/versions/fecb5e4a7be4_blank_initial_database.py @@ -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 ### diff --git a/nemesis.conf.sample b/nemesis.conf.sample index a946da5..a67e641 100644 --- a/nemesis.conf.sample +++ b/nemesis.conf.sample @@ -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