コード例 #1
0
def do_upgrade():
    """ Implement your upgrades here  """
    m = db.MetaData(bind=db.engine)
    m.reflect()

    tpid = db.Table(
        'pid',
        m,
        db.Column('id', db.Integer(15, unsigned=True), primary_key=True, nullable=False),
        db.Column('type', db.String(length=6), nullable=False),
        db.Column('pid', db.String(length=255), nullable=False),
        db.Column('status', db.Char(length=1), nullable=False),
        db.Column('created', db.DateTime(), nullable=False),
        db.Column('last_modified', db.DateTime(), nullable=False),
        db.Index('uidx_type_pid', 'type', 'pid', unique=True),
        db.Index('idx_status', 'status'),
        mysql_engine='MyISAM',
    )

    tpidlog = db.Table(
        'pidLOG',
        m,
        db.Column('id', db.Integer(15, unsigned=True), primary_key=True, nullable=False),
        db.Column('id_pid', db.Integer(15, unsigned=True), ForeignKey('pid.id')),
        db.Column('timestamp', DateTime(), nullable=False),
        db.Column('action', db.String(length=10), nullable=False),
        db.Column('message', Text(), nullable=False),
        db.Index('idx_action', 'action'),
        mysql_engine='MyISAM',
    )

    tpidregistry = db.Table(
        'pidREGISTRY',
        m,
        db.Column('object_type', db.String(length=3), primary_key=True, nullable=False),
        db.Column('object_id', db.String(length=255), nullable=False),
        db.Column('id_pid', db.Integer(15, unsigned=True), ForeignKey('pid.id'), primary_key=True, nullable=False),
        db.Index('idx_type_id', 'object_type', 'object_id'),
        mysql_engine='MyISAM',
    )

    tpid.create()
    tpidlog.create()
    tpidregistry.create()
コード例 #2
0
def do_upgrade():
    """ Implement your upgrades here  """
    m = db.MetaData(bind=db.engine)
    m.reflect()
    t = db.Table(
        'userCOLLECTION',
        m,
        db.Column('id',
                  db.String(length=100),
                  primary_key=True,
                  nullable=False),
        db.Column('id_user',
                  db.Integer(15, unsigned=True),
                  db.ForeignKey('user.id'),
                  nullable=False),
        db.Column('id_collection',
                  db.MediumInteger(9, unsigned=True),
                  db.ForeignKey('collection.id'),
                  nullable=True),
        db.Column('id_collection_provisional',
                  db.MediumInteger(9, unsigned=True),
                  db.ForeignKey('collection.id'),
                  nullable=True),
        db.Column('id_oairepository',
                  db.MediumInteger(9, unsigned=True),
                  db.ForeignKey('oaiREPOSITORY.id'),
                  nullable=True),
        db.Column('title', db.String(length=255), nullable=False),
        db.Column('description', db.Text(), nullable=False),
        db.Column('page', db.Text(), nullable=False),
        db.Column('curation_policy', db.Text(), nullable=False),
        db.Column('has_logo', db.Boolean(), nullable=False),
        db.Column('created', db.DateTime(), nullable=False),
        db.Column('last_modified', db.DateTime(), nullable=False),
        mysql_engine='MyISAM',
    )
    t.create()
コード例 #3
0
ファイル: models.py プロジェクト: chokribr/invenio-1
"""Authors data models."""

from sqlalchemy.orm.exc import MultipleResultsFound

from invenio.ext.sqlalchemy import db, utils
from invenio.modules.accounts.models import User
from invenio.modules.records.models import Record
from invenio.modules.records.api import get_record

from .errors import SignatureExistsError

# The 'authors_citation' table is an association table of publications.
# An 'authors_publication' cites an other 'authors_publication'.
Citation = db.Table(
    'authors_citation', db.metadata,
    db.Column('citer', db.Integer(15, unsigned=True),
              db.ForeignKey('authors_publication.id')),
    db.Column('cited', db.Integer(15, unsigned=True),
              db.ForeignKey('authors_publication.id')))


class Publication(db.Model):
    """Model representing a publication entity.

    Each publication is associated to an Invenio bibrec (record),
    may have authors and may contain references to other publications.
    Finally, each publication may have citations by other publications.
    """

    __tablename__ = 'authors_publication'

    # When deleting a number of signatures, it should not be expected