DB schema for Refstack API v1
Includes autogenerated alembic migration. Change-Id: I090adeda1b7891955f6285ed26c1d34e4c46ef69
This commit is contained in:
parent
c6713320ac
commit
a11dcb8487
@ -31,9 +31,9 @@ fileConfig(config.config_file_name)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
from refstack.models import db
|
||||
target_metadata = db.metadata
|
||||
#target_metadata = None
|
||||
from refstack.models import Base
|
||||
target_metadata = Base.metadata
|
||||
# target_metadata = None
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
|
55
alembic/versions/42278d6179b9_init.py
Normal file
55
alembic/versions/42278d6179b9_init.py
Normal file
@ -0,0 +1,55 @@
|
||||
"""Init
|
||||
|
||||
Revision ID: 42278d6179b9
|
||||
Revises: None
|
||||
Create Date: 2015-01-09 15:00:11.385580
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '42278d6179b9'
|
||||
down_revision = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'test',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('cpid', sa.String(length=128), nullable=False),
|
||||
sa.Column('duration_seconds', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'meta',
|
||||
sa.Column('_id', sa.Integer(), nullable=False),
|
||||
sa.Column('test_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('meta_key', sa.String(length=64), nullable=False),
|
||||
sa.Column('value', sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['test_id'], ['test.id'], ),
|
||||
sa.PrimaryKeyConstraint('_id'),
|
||||
sa.UniqueConstraint('test_id', 'meta_key')
|
||||
)
|
||||
op.create_table(
|
||||
'results',
|
||||
sa.Column('_id', sa.Integer(), nullable=False),
|
||||
sa.Column('test_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=1024), nullable=True),
|
||||
sa.Column('uid', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['test_id'], ['test.id'], ),
|
||||
sa.PrimaryKeyConstraint('_id'),
|
||||
sa.UniqueConstraint('test_id', 'name'),
|
||||
sa.UniqueConstraint('test_id', 'uid')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('results')
|
||||
op.drop_table('meta')
|
||||
op.drop_table('test')
|
||||
### end Alembic commands ###
|
@ -14,105 +14,43 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from datetime import datetime
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
from refstack.extensions import db
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class User(db.Model):
|
||||
__tablename__ = 'user'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
vendor_id = db.Column(db.Integer, db.ForeignKey('vendor.id'))
|
||||
vendor = db.relationship('Vendor',
|
||||
backref=db.backref('clouds',
|
||||
lazy='dynamic'))
|
||||
name = db.Column(db.String(60))
|
||||
email = db.Column(db.String(200), unique=True)
|
||||
email_verified = db.Column(db.Boolean)
|
||||
openid = db.Column(db.String(200), unique=True)
|
||||
authorized = db.Column(db.Boolean, default=False)
|
||||
su = db.Column(db.Boolean, default=False)
|
||||
|
||||
def __init__(self, name, email, openid):
|
||||
self.name = name
|
||||
self.email = email
|
||||
self.openid = openid
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class ApiKey(db.Model):
|
||||
__tablename__ = 'apikey'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(60))
|
||||
key = db.Column(db.String(200))
|
||||
openid = db.Column(db.String(200))
|
||||
timestamp = db.Column(db.DateTime, default=datetime.now)
|
||||
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
||||
user = db.relationship('User',
|
||||
backref=db.backref('apikeys', lazy='dynamic'))
|
||||
|
||||
|
||||
class Vendor(db.Model):
|
||||
"""Note: The vendor list will be pre-populated from the
|
||||
sponsoring company database.
|
||||
TODO: better define the vendor object and its relationship with user
|
||||
it needs the ability to facilitate a login.
|
||||
"""
|
||||
__tablename__ = 'vendor'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
vendor_name = db.Column(db.String(80), unique=True)
|
||||
contact_email = db.Column(db.String(120), unique=True)
|
||||
contact_name = db.Column(db.String(120), unique=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.vendor_name
|
||||
|
||||
|
||||
class Cloud(db.Model):
|
||||
"""*need to take the time to descibe this stuff in detail.
|
||||
"""
|
||||
__tablename__ = 'cloud'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
label = db.Column(db.String(60), unique=False)
|
||||
endpoint = db.Column(db.String(512), unique=False)
|
||||
endpoint_v3 = db.Column(db.String(512), unique=False)
|
||||
admin_endpoint = db.Column(db.String(512), unique=False)
|
||||
test_user = db.Column(db.String(80), unique=False)
|
||||
alt_user = db.Column(db.String(80), unique=False)
|
||||
admin_user = db.Column(db.String(80), unique=False)
|
||||
version = db.Column(db.String(80), unique=False)
|
||||
tempest_sha = db.Column(db.String(128), unique=False)
|
||||
architecture = db.Column(db.String(40), unique=False)
|
||||
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
||||
user = db.relationship('User',
|
||||
backref=db.backref('clouds', lazy='dynamic'))
|
||||
|
||||
|
||||
class Test(db.Model):
|
||||
class Test(Base):
|
||||
__tablename__ = 'test'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
cloud_id = db.Column(db.Integer, db.ForeignKey('cloud.id'))
|
||||
cloud = db.relationship('Cloud',
|
||||
backref=db.backref('tests', lazy='dynamic'))
|
||||
finished = db.Column(db.Boolean, default=False)
|
||||
subunit = db.Column(db.String(4096))
|
||||
parsed = db.Column(db.String(4096))
|
||||
|
||||
id = sa.Column(sa.String(36), primary_key=True)
|
||||
cpid = sa.Column(sa.String(128), index=True, nullable=False)
|
||||
duration_seconds = sa.Column(sa.Integer, nullable=False)
|
||||
results = orm.relationship('TestResults', backref='test')
|
||||
meta = orm.relationship('TestMeta', backref='test')
|
||||
|
||||
|
||||
class TestStatus(db.Model):
|
||||
__tablename__ = 'test_status'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
test_id = db.Column(db.Integer, db.ForeignKey('test.id'))
|
||||
test = db.relationship('Test',
|
||||
backref=db.backref('status', lazy='dynamic'))
|
||||
message = db.Column(db.String(1024))
|
||||
timestamp = db.Column(db.DateTime, default=datetime.now)
|
||||
class TestResults(Base):
|
||||
__tablename__ = 'results'
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('test_id', 'name'),
|
||||
sa.UniqueConstraint('test_id', 'uid'),
|
||||
)
|
||||
_id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||
test_id = sa.Column(sa.String(36), sa.ForeignKey('test.id'),
|
||||
index=True, nullable=False, unique=False)
|
||||
name = sa.Column(sa.String(1024))
|
||||
uid = sa.Column(sa.String(36))
|
||||
|
||||
def __init__(self, test_id, message, finished=False):
|
||||
self.test_id = test_id
|
||||
self.message = message
|
||||
self.finished = finished
|
||||
|
||||
class TestMeta(Base):
|
||||
__tablename__ = 'meta'
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('test_id', 'meta_key'),
|
||||
)
|
||||
_id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||
test_id = sa.Column(sa.String(36), sa.ForeignKey('test.id'),
|
||||
index=True, nullable=False, unique=False)
|
||||
meta_key = sa.Column(sa.String(64), index=True, nullable=False)
|
||||
value = sa.Column(sa.Text())
|
||||
|
Loading…
Reference in New Issue
Block a user