Пример #1
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('informed_consent_document',
                    'html',
                    existing_type=postgresql.BYTEA(),
                    type_=postgresql.TEXT(),
                    nullable=True)
Пример #2
0
class Book(Base):
    __tablename__ = 'book'

    id = sa.Column(
        postgresql_types.UUID(),
        default=GET_DEFAULT('books.models.Book.id'),
        primary_key=True,
        unique=True,
        nullable=False,
    )
    price = sa.Column(
        postgresql_types.JSONB(),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    title = sa.Column(
        postgresql_types.VARCHAR(length=255),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    description = sa.Column(
        postgresql_types.TEXT(),
        primary_key=False,
        unique=False,
        nullable=True,
    )
    author_id = sa.Column(
        postgresql_types.INTEGER(),
        sa.ForeignKey(column="author.id", ondelete="SET_NULL"),
        primary_key=False,
        unique=False,
        nullable=True,
        autoincrement=True,
    )
    content = sa.Column(
        postgresql_types.BYTEA(),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    tags = sa.Column(
        postgresql_types.ARRAY(item_type=postgresql_types.VARCHAR,
                               dimensions=1),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    author = sa.orm.relationship(
        'Author',
        foreign_keys="[book.c.author_id]",
        remote_side=None,
    )
    category = sa.orm.relationship(
        'Category',
        secondary="book_category",
        foreign_keys="[book_category.c.book_id, book_category.c.category_id]",
        remote_side=None,
    )
class Text(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(120), nullable=False, default=str(id))
    text = db.Column(postgresql.TEXT(), nullable=False)
    created = db.Column(db.DateTime(), default=datetime.utcnow)
    restaurant_id = db.Column(db.Integer,
                              db.ForeignKey('restaurant.id'),
                              nullable=False)

    texts_active = db.relationship('TextActive',
                                   backref=db.backref('text', lazy='joined'),
                                   lazy=True)

    def to_dict(self):
        data = {
            'id': self.id,
            'title': html.unescape(self.title),
            'text': html.unescape(self.text),
            'created': self.created,
            '_links': {
                'self': url_for('api.update_texts', id=self.id)
            }
        }
        return data

    def from_dict(self, data):
        for field in ['title', 'text']:
            if field in data:
                setattr(self, field, data[field])
        db.session.add(self)

    def __repr__(self):
        return '<Text {}: {}>'.format(self.id, self.title)
Пример #4
0
class Subscription(Base):
    __tablename__ = 'subscriptions'

    id = Column(Integer, primary_key=True, autoincrement=True)

    platform = Column(Text, nullable=False)
    name = Column(Text, nullable=False)

    polarization = Column(ARRAY(postgresql.TEXT()), nullable=False)
    orbit_dir = Column(Text, nullable=False)

    paths = Column(ARRAY(postgresql.INT4RANGE()), nullable=False)

    location = Column(Geometry(geometry_type='MULTIPOLYGON', srid=4326),
                      index=True,
                      nullable=False)

    start_date = Column(Date)
    end_date = Column(Date)
    start_date_handled = Column(Boolean,
                                nullable=False,
                                server_default=sql.expression.text("false"))

    process_old = Column(Boolean, nullable=False)
    process_id = Column(ForeignKey('processes.id',
                                   deferrable=True,
                                   initially='DEFERRED'),
                        nullable=False,
                        index=True)

    user_id = Column(ForeignKey('users.id',
                                deferrable=True,
                                initially='DEFERRED'),
                     nullable=False,
                     index=True)

    crop_to_selection = Column(Boolean, nullable=False)
    extra_arguments = Column(Text)

    enabled = Column(Boolean,
                     nullable=False,
                     server_default=sql.expression.text("true"))

    project_id = Column(ForeignKey('projects.id'))
    description = Column(Text)
    priority = Column(Integer,
                      nullable=False,
                      server_default=sql.expression.text("10"))

    process = orm.relationship('Process')
    project = orm.relationship('Project')
    user = orm.relationship('User')
    groups = orm.relationship('Group',
                              secondary=subscriptions_in_groups,
                              lazy='joined')
Пример #5
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('informed_consent_document',
                    'html',
                    existing_type=postgresql.TEXT(),
                    type_=postgresql.BYTEA(),
                    nullable=True)
    # ### end Alembic commands ###


#, postgresql_using='html::varchar'
Пример #6
0
class Session(Base):
    __tablename__ = 'django_session'

    session_key = sa.Column(
        postgresql_types.VARCHAR(length=40),
        primary_key=True,
        unique=True,
        nullable=False,
    )
    session_data = sa.Column(
        postgresql_types.TEXT(),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    expire_date = sa.Column(
        postgresql_types.TIMESTAMP(),
        primary_key=False,
        unique=False,
        nullable=False,
    )
Пример #7
0
class LogEntry(Base):
    __tablename__ = 'django_admin_log'

    id = sa.Column(
        postgresql_types.INTEGER(),
        primary_key=True,
        unique=True,
        nullable=False,
        autoincrement=True,
    )
    action_time = sa.Column(
        postgresql_types.TIMESTAMP(),
        default=GET_DEFAULT(
            'django.contrib.admin.models.LogEntry.action_time'),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    user_id = sa.Column(
        postgresql_types.INTEGER(),
        sa.ForeignKey(column="auth_user.id", ondelete="CASCADE"),
        primary_key=False,
        unique=False,
        nullable=False,
        autoincrement=True,
    )
    content_type_id = sa.Column(
        postgresql_types.INTEGER(),
        sa.ForeignKey(column="django_content_type.id", ondelete="SET_NULL"),
        primary_key=False,
        unique=False,
        nullable=True,
        autoincrement=True,
    )
    object_id = sa.Column(
        postgresql_types.TEXT(),
        primary_key=False,
        unique=False,
        nullable=True,
    )
    object_repr = sa.Column(
        postgresql_types.VARCHAR(length=200),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    action_flag = sa.Column(
        postgresql_types.SMALLINT(),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    change_message = sa.Column(
        postgresql_types.TEXT(),
        primary_key=False,
        unique=False,
        nullable=False,
    )
    user = sa.orm.relationship(
        'User',
        foreign_keys="[django_admin_log.c.user_id]",
        remote_side=None,
    )
    content_type = sa.orm.relationship(
        'ContentType',
        foreign_keys="[django_admin_log.c.content_type_id]",
        remote_side=None,
    )
           autoincrement=False),
    Column("collection",
           Integer,
           primary_key=True,
           nullable=False,
           autoincrement=False),
    Column("last_modified", BigInteger, nullable=False))

# Column definitions for BSO storage table/tables.
#
# This list class defines the columns used for storage of BSO records.
# It is used to create either sharded or non-shareded BSO storage tables,
# depending on the run-time settings of the application.

PAYLOAD_TYPE = Text()
PAYLOAD_TYPE = PAYLOAD_TYPE.with_variant(postgresql.TEXT(), 'postgresql')
PAYLOAD_TYPE = PAYLOAD_TYPE.with_variant(mysql.MEDIUMTEXT(), 'mysql')

# Common column definitions between BSO and batch upload item tables


def _get_bso_columns(table_name):
    return (
        Column("userid",
               Integer,
               primary_key=True,
               nullable=False,
               autoincrement=False),
        Column("collection",
               Integer,
               primary_key=True,
Пример #9
0
 def test_text(self):
     result = format_partition_value(postgresql.TEXT(), 'something')
     assert result == '\'something\''
Пример #10
0
def upgrade():
    op.create_table(
        'project',
        sa.Column('id', postgresql.INTEGER(), nullable=False, primary_key=True),
        sa.Column('name', postgresql.VARCHAR(255), nullable=False),
        sa.Column('data_source_query', postgresql.VARCHAR(1024), nullable=True)
    )

    op.create_table(
        'team',
        sa.Column('id', postgresql.INTEGER(), nullable=False, primary_key=True),
        sa.Column('name', postgresql.VARCHAR(255), nullable=False),
        sa.Column('bugfix_rate', postgresql.FLOAT(), nullable=False),
    )

    op.create_table(
        'project_history',
        sa.Column('begin_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('end_datetime', postgresql.TIMESTAMP(), nullable=True),
        sa.Column('project_id', postgresql.INTEGER(), nullable=False),
        sa.Column('scope_complete_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('feature_complete_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('ready_to_manufacture_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('owner_team_id', postgresql.INTEGER(), nullable=False),
        sa.Column('comment', postgresql.TEXT(), nullable=True),
        sa.ForeignKeyConstraint(
            ('project_id',),
            ('project.id',),
            name='project_history_project_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('owner_team_id',),
            ('team.id',),
            name='project_history_owner_team_id_fk',
        ),
        sa.UniqueConstraint('begin_datetime', 'project_id', name='project_history_begin_datetime_project_id_idx'),
    )

    op.create_table(
        'known_bugs_count_history',
        sa.Column('begin_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('end_datetime', postgresql.TIMESTAMP(), nullable=True),
        sa.Column('project_id', postgresql.INTEGER(), nullable=False),
        sa.Column('team_id', postgresql.INTEGER(), nullable=False),
        sa.Column('known_bugs_count', postgresql.INTEGER(), nullable=False),
        sa.ForeignKeyConstraint(
            ('project_id',),
            ('project.id',),
            name='project_history_project_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('team_id',),
            ('team.id',),
            name='project_history_owner_team_id_fk',
        ),
        sa.UniqueConstraint(
            'begin_datetime', 'project_id', 'team_id',
            name='known_bugs_count_history_begin_datetime_project_id_team_id_idx'
        ),
    )

    op.create_table(
        'person',
        sa.Column('id', postgresql.INTEGER(), nullable=False, primary_key=True),
        sa.Column('firstname', postgresql.VARCHAR(255), nullable=False),
        sa.Column('lastname', postgresql.VARCHAR(255), nullable=False),
        sa.Column('issue_tracker_name', postgresql.VARCHAR(255), nullable=False),
    )

    op.create_table(
        'person_history',
        sa.Column('begin_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('end_datetime', postgresql.TIMESTAMP(), nullable=True),
        sa.Column('person_id', postgresql.INTEGER(), nullable=False),
        sa.Column('team_id', postgresql.INTEGER(), nullable=False),
        sa.Column('project_id', postgresql.INTEGER(), nullable=False),
        sa.Column('project_assignment', postgresql.FLOAT(), nullable=False),
        sa.Column('comment', postgresql.TEXT(), nullable=True),
        sa.ForeignKeyConstraint(
            ('person_id',),
            ('person.id',),
            name='person_history_person_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('team_id',),
            ('team.id',),
            name='person_history_team_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('project_id',),
            ('project.id',),
            name='person_history_project_id_fk',
        ),
        sa.UniqueConstraint(
            'begin_datetime', 'person_id', 'team_id', 'project_id',
            name='person_history_begin_datetime_person_id_team_id_project_id_idx'
        ),
    )

    op.create_table(
        'issue_type',
        sa.Column('id', postgresql.INTEGER(), nullable=False, primary_key=True),
        sa.Column('name', postgresql.VARCHAR(255), nullable=False),
    )

    op.create_table(
        'implementation_type',
        sa.Column('id', postgresql.INTEGER(), nullable=False, primary_key=True),
        sa.Column('name', postgresql.VARCHAR(255), nullable=False),
    )

    op.create_table(
        'issue',
        sa.Column('id', postgresql.BIGINT(), nullable=False, primary_key=True),
        sa.Column('key', postgresql.VARCHAR(64), nullable=False),
        sa.Column('url', postgresql.VARCHAR(255), nullable=False),
        sa.Column('created', postgresql.TIMESTAMP(), nullable=False),
    )

    op.create_table(
        'issue_history',
        sa.Column('begin_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('end_datetime', postgresql.TIMESTAMP(), nullable=True),
        sa.Column('issue_id', postgresql.BIGINT(), nullable=False),
        sa.Column('type_id', postgresql.INTEGER(), nullable=False),
        sa.Column('resolved', postgresql.INTEGER(), nullable=True, default=None),
        sa.Column('due', postgresql.DATE(), nullable=True, default=None),
        sa.Column('summary', postgresql.VARCHAR(255), nullable=False),
        sa.Column('components', postgresql.VARCHAR(255), nullable=True),
        sa.Column('assignee_id', postgresql.INTEGER(), nullable=False),
        sa.Column('reporter_id', postgresql.INTEGER(), nullable=False),
        sa.Column('status', postgresql.VARCHAR(255), nullable=False),
        sa.Column('reqs_level', postgresql.FLOAT(), nullable=True),
        sa.Column('design_level', postgresql.FLOAT(), nullable=True),
        sa.Column('comment', postgresql.TEXT(), nullable=True),
        sa.ForeignKeyConstraint(
            ('issue_id',),
            ('issue.id',),
            name='issue_history_issue_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('type_id',),
            ('issue_type.id',),
            name='issue_history_type_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('assignee_id',),
            ('person.id',),
            name='issue_history_assignee_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('reporter_id',),
            ('person.id',),
            name='issue_history_reporter_id_fk',
        ),
        sa.UniqueConstraint(
            'begin_datetime', 'issue_id',
            name='issue_history_begin_datetime_issue_id_idx'
        ),
    )

    op.create_table(
        'original_estimate',
        sa.Column('begin_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('end_datetime', postgresql.TIMESTAMP(), nullable=True),
        sa.Column('issue_id', postgresql.BIGINT(), nullable=False),
        sa.Column('team_id', postgresql.INTEGER(), nullable=False),
        sa.Column('implementation_type_id', postgresql.INTEGER(), nullable=False),
        sa.Column('estimation', postgresql.FLOAT(), nullable=True),
        sa.Column('comment', postgresql.TEXT(), nullable=True),
        sa.ForeignKeyConstraint(
            ('issue_id',),
            ('issue.id',),
            name='original_estimate_issue_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('team_id',),
            ('team.id',),
            name='original_estimate_team_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('implementation_type_id',),
            ('implementation_type.id',),
            name='original_estimate_implementation_type_id_fk',
        ),
        sa.UniqueConstraint(
            'begin_datetime', 'issue_id', 'team_id',
            name='original_estimate_begin_datetime_issue_id_team_id_idx'
        ),
    )

    op.create_table(
        'remaining_estimate',
        sa.Column('begin_datetime', postgresql.TIMESTAMP(), nullable=False),
        sa.Column('end_datetime', postgresql.TIMESTAMP(), nullable=True),
        sa.Column('issue_id', postgresql.BIGINT(), nullable=False),
        sa.Column('team_id', postgresql.INTEGER(), nullable=False),
        sa.Column('implementation_type_id', postgresql.INTEGER(), nullable=False),
        sa.Column('estimation', postgresql.FLOAT(), nullable=True),
        sa.Column('comment', postgresql.TEXT(), nullable=True),
        sa.ForeignKeyConstraint(
            ('issue_id',),
            ('issue.id',),
            name='remaining_estimate_issue_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('team_id',),
            ('team.id',),
            name='remaining_estimate_team_id_fk',
        ),
        sa.ForeignKeyConstraint(
            ('implementation_type_id',),
            ('implementation_type.id',),
            name='remaining_estimate_implementation_type_id_fk',
        ),
        sa.UniqueConstraint(
            'begin_datetime', 'issue_id', 'team_id',
            name='remaining_estimate_begin_datetime_issue_id_team_id_idx'
        ),
    )