Python sqlalchemy.DateTime() Examples

The following are code examples for showing how to use sqlalchemy.DateTime(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: eventor   Author: Acrisel   File: dbschema.py    (license) View Source Project 8 votes vote down vote up
def delay_table(base):
    class Delay(base):
        __tablename__ = 'Delay'
        
        id_=Column(Integer, Sequence('delay_id_seq'), primary_key=True)
        run_id = Column(String, default='')
        delay_id = Column(String,)
        sequence = Column(Integer,)
        recovery = Column(Integer,)
        seconds = Column(BigInteger, nullable=True)
        active = Column(Boolean, default=False)
        activated = Column(DateTime(), nullable=True,) 
        updated = Column(DateTime(), default=datetime.utcnow) 
        
        __table_args__ = (
                UniqueConstraint('run_id', 'delay_id', 'sequence', 'recovery'),
                )
    
        def __repr__(self):
            return "<Delay(id='%s', run_id='%s', delay_id='%s', delay='%s', active='%s', activated='%s')>" % (
                self.id_, self.run_id, self.delay_id, self.seconds, self.active, self.activated)
    
    return Delay 
Example 2
Project: fabric8-analytics-server   Author: fabric8-analytics   File: b4fbc8e04c81_gh_usage_with_versions.py    (license) View Source Project 8 votes vote down vote up
def upgrade():
    """Upgrade the database to a newer revision."""
    # commands auto generated by Alembic - please adjust! ###
    op.create_table('component_gh_usage',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=255), nullable=False),
                    sa.Column('version', sa.String(length=255), nullable=False),
                    sa.Column('count', sa.Integer(), nullable=False),
                    sa.Column('ecosystem_backend', postgresql.ENUM('none', 'npm', 'maven', 'pypi',
                                                                   'rubygems', 'scm', 'crates',
                                                                   name='ecosystem_backend_enum',
                                                                   create_type=False),
                              nullable=True),
                    sa.Column('timestamp', sa.DateTime(), server_default=sa.text('LOCALTIMESTAMP'),
                              nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    # end Alembic commands ### 
Example 3
Project: podigger   Author: perna   File: 012722a93d11_.py    (license) View Source Project 7 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('topic_suggestion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('is_recorded', sa.Boolean(), nullable=False),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_topic_suggestion_id'), 'topic_suggestion', ['id'], unique=False)
    op.create_index(op.f('ix_topic_suggestion_title'), 'topic_suggestion', ['title'], unique=False)
    op.create_index(op.f('ix_episode_id'), 'episode', ['id'], unique=False)
    op.create_index(op.f('ix_podcast_id'), 'podcast', ['id'], unique=False)
    op.create_index(op.f('ix_popular_term_id'), 'popular_term', ['id'], unique=False)
    op.create_index(op.f('ix_tag_id'), 'tag', ['id'], unique=False)
    ### end Alembic commands ### 
Example 4
Project: fabric8-analytics-server   Author: fabric8-analytics   File: 963d3d929b19_analyses.py    (license) View Source Project 7 votes vote down vote up
def upgrade():
    """Upgrade the database to a newer revision."""
    # commands auto generated by Alembic - please adjust! ###
    op.create_table('analyses',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('ecosystem', sa.Integer(), nullable=True),
                    sa.Column('package', sa.String(length=255), nullable=True),
                    sa.Column('version', sa.String(length=255), nullable=True),
                    sa.Column('access_count', sa.Integer(), nullable=True),
                    sa.Column('started_at', sa.DateTime(), nullable=True),
                    sa.Column('finished_at', sa.DateTime(), nullable=True),
                    sa.Column('analyses', postgresql.JSONB(), nullable=True),
                    sa.Column('subtasks', postgresql.JSONB(), nullable=True),
                    sa.Column('release', sa.String(length=255), nullable=True),
                    sa.Column('audit', postgresql.JSONB(), nullable=True),
                    sa.PrimaryKeyConstraint('id'))
    op.create_table('worker_results',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('worker', sa.String(length=255), nullable=True),
                    sa.Column('analysis_id', sa.Integer(), nullable=True),
                    sa.Column('task_result', postgresql.JSONB(), nullable=True),
                    sa.ForeignKeyConstraint(['analysis_id'], ['analyses.id'], ),
                    sa.PrimaryKeyConstraint('id'))
    # end Alembic commands ### 
Example 5
Project: knowledge-repo   Author: airbnb   File: dbrepository.py    (license) View Source Project 7 votes vote down vote up
def init(self, auto_create=True):

        # TODO handle if user does not pass in table sqlite://path.db
        uri_splt = self.uri.split(":")
        engine_uri = u":".join(uri_splt[:-1])
        table_name = uri_splt[-1]

        metadata = MetaData()
        postref_table = Table(table_name, metadata,
                              Column('id', Integer, primary_key=True),
                              Column('created_at', DateTime, default=func.now()),
                              Column('updated_at', DateTime, default=func.now(), onupdate=func.current_timestamp()),
                              Column('uuid', String(512)),
                              Column('path', String(512)),
                              Column('revision', Integer, default=0),
                              Column('status', Integer, default=self.PostStatus.DRAFT.value),
                              Column('ref', String(512)),
                              Column('data', LargeBinary))
        self.engine = create_engine(engine_uri, pool_recycle=3600)
        self.session = scoped_session(sessionmaker(bind=self.engine))
        if auto_create:
            postref_table.create(self.engine, checkfirst=True)

        class PostRef(object):
            pass
        mapper(PostRef, postref_table)
        self.PostRef = PostRef

    # ------------- Repository actions / state ------------------------------------ 
Example 6
Project: centr   Author: ibiBgOR   File: 8a3e1e2_initial_model.py    (license) View Source Project 7 votes vote down vote up
def upgrade():
    op.create_table("db_log_item",
        sa.Column("id", sa.Integer, primary_key = True),
        sa.Column("message", sa.Text),
        sa.Column("time", sa.DateTime),
        sa.Column("level", sa.String(5)),
        sa.Column("trace", sa.Text),
    )
    op.create_table("db_feed_item",
        sa.Column("id", sa.Integer, primary_key = True),
        sa.Column("content", sa.Text),
        sa.Column("type", sa.String(20)),
        sa.Column("source", sa.String(125)),
        sa.Column("time", sa.DateTime),
        sa.UniqueConstraint('content', 'source', name = 'uk_content_source'),
    ) 
Example 7
Project: cyborg   Author: openstack   File: f50980397351_initial_migration.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'accelerators',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('project_id', sa.String(length=36), nullable=True),
        sa.Column('user_id', sa.String(length=36), nullable=True),
        sa.Column('device_type', sa.Text(), nullable=False),
        sa.Column('acc_type', sa.Text(), nullable=False),
        sa.Column('acc_capability', sa.Text(), nullable=False),
        sa.Column('vendor_id', sa.Text(), nullable=False),
        sa.Column('product_id', sa.Text(), nullable=False),
        sa.Column('remotable', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_ENGINE='InnoDB',
        mysql_DEFAULT_CHARSET='UTF8'
    ) 
Example 8
Project: bit   Author: codesmart-co   File: 4ad33f99723a_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('bit_facebook_daily_ad_insights_impression_device',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('account_id', sa.String(length=255), nullable=True),
    sa.Column('campaign_id', sa.String(length=255), nullable=True),
    sa.Column('adset_id', sa.String(length=255), nullable=True),
    sa.Column('campaign_name', sa.String(length=255), nullable=True),
    sa.Column('spend', sa.Numeric(), nullable=True),
    sa.Column('cost_per_unique_click', sa.Numeric(), nullable=True),
    sa.Column('unique_clicks', sa.Integer(), nullable=True),
    sa.Column('unique_impressions', sa.Integer(), nullable=True),
    sa.Column('unique_social_clicks', sa.Integer(), nullable=True),
    sa.Column('unique_social_impressions', sa.Integer(), nullable=True),
    sa.Column('website_clicks', sa.Integer(), nullable=True),
    sa.Column('date_start', sa.DateTime(), nullable=True),
    sa.Column('date_stop', sa.DateTime(), nullable=True),
    sa.Column('impression_device', sa.String(length=255), nullable=True),
    sa.Column('ad_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['ad_id'], ['bit_facebook_ad.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_bit_facebook_daily_ad_insights_impression_device_impression_device'), 'bit_facebook_daily_ad_insights_impression_device', ['impression_device'], unique=False)
    # ### end Alembic commands ### 
Example 9
Project: ibstract   Author: jesseliu0   File: marketdata.py    (license) View Source Project 6 votes vote down vote up
def _gen_sa_table(sectype, metadata=None):
    """Generate SQLAlchemy Table object by sectype.
    """
    if metadata is None:
        metadata = MetaData()
    table = Table(
        sectype, metadata,
        Column('Symbol', String(20), primary_key=True),
        Column('DataType', String(20), primary_key=True),
        Column('BarSize', String(10), primary_key=True),
        Column('TickerTime', DateTime(), primary_key=True),
        Column('opening', Float(10, 2)),
        Column('high', Float(10, 2)),
        Column('low', Float(10, 2)),
        Column('closing', Float(10, 2)),
        Column('volume', mysqlINTEGER(unsigned=True)),
        Column('barcount', mysqlINTEGER(unsigned=True)),
        Column('average', Float(10, 2))
    )
    return table 
Example 10
Project: eventor   Author: Acrisel   File: dbschema.py    (license) View Source Project 6 votes vote down vote up
def trigger_table(base):
    class Trigger(base):
        __tablename__ = 'Trigger'
        
        id_ = Column(Integer, Sequence('trigger_id_seq'), primary_key=True)
        run_id = Column(String, nullable=False, default='')
        event_id = Column(String, nullable=False)
        sequence = Column(Integer, nullable=False)
        recovery = Column(Integer, nullable=False, default=0)
        created = Column(DateTime(), default=datetime.utcnow) 
        acted = Column(DateTime(), nullable=True) 
    
        def __repr__(self):
            return "<Trigger(id='%s', run_id='%s', event_id='%s', sequence='%s', recovery='%s', created='%s', acted='%s')>" % (
                self.id_, self.run_id, self.event_id, self.sequence, self.recovery, self.created, self.acted)
    
    return Trigger 
Example 11
Project: fuel-plugin-dns-updater   Author: openstack   File: db_setup.py    (license) View Source Project 6 votes vote down vote up
def init_tables():
    db_instance = Table("instance", dbmeta,
          Column("id", Integer, primary_key=True),
          Column("ip", String(20)),
          Column("name", String(90)),
          Column("uuid", String(40)),
          Column("state", String(90)),
          Column("dns_domain", String(90)),
          Column("created_at", DateTime),
          Column("updated_at", DateTime),
          Column("deleted_at", DateTime)
    )
    db_event = Table("event", dbmeta,
          #will be used for synchronization
          Column("id", Integer, primary_key=True),
          Column("fk_instance_id", Integer, ForeignKey("instance.id")),
          Column("type", String(24)),#enum
          Column("description", String(90)),
          Column("date", DateTime)
    )
    dbmeta.drop_all(dbengine)
    dbmeta.create_all(dbengine) 
Example 12
Project: podigger   Author: perna   File: 5c5dc0258b2f_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('episode',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('link', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('published', sa.DateTime(), nullable=True),
    sa.Column('enclosure', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('link'),
    sa.UniqueConstraint('title')
    )
    op.create_index(op.f('ix_podcast_feed'), 'podcast', ['feed'], unique=True)
    op.create_index(op.f('ix_podcast_name'), 'podcast', ['name'], unique=True)
    ### end Alembic commands ### 
Example 13
Project: zun   Author: openstack   File: 10d65e285a59_create_volume_mapping_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'volume_mapping',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(36), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('volume_id', sa.String(36), nullable=False),
        sa.Column('volume_provider', sa.String(36), nullable=False),
        sa.Column('container_uuid', sa.String(36), nullable=False),
        sa.Column('container_path', sa.String(length=255), nullable=True),
        sa.Column('connection_info', MediumText(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_volume0uuid'),
    ) 
Example 14
Project: zun   Author: openstack   File: b6bfca998431_add_container_actions_events_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container_actions_events',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('event', sa.String(length=255), nullable=True),
        sa.Column('action_id', sa.Integer(), nullable=False),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('result', sa.String(length=255), nullable=True),
        sa.Column('traceback', sa.Text(), nullable=True),
        sa.Column('details', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(['action_id'], ['container_actions.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example 15
Project: zun   Author: openstack   File: 9fe371393a24_create_table_container.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('image', sa.String(length=255), nullable=True),
        sa.Column('command', sa.String(length=255), nullable=True),
        sa.Column('status', sa.String(length=20), nullable=True),
        sa.Column('environment', zun.db.sqlalchemy.models.JSONEncodedDict(),
                  nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_container0uuid')
    ) 
Example 16
Project: zun   Author: openstack   File: 72c6947c6636_create_table_image.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # commands auto generated by Alembic - please adjust! #
    op.create_table(
        'image',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('image_id', sa.String(length=255), nullable=True),
        sa.Column('repo', sa.String(length=255), nullable=True),
        sa.Column('tag', sa.String(length=255), nullable=True),
        sa.Column('size', sa.String(length=255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('repo', 'tag', name='uniq_image0repotag'),
        mysql_charset='utf8',
        mysql_engine='InnoDB'
        )
    #  end Alembic commands # 
Example 17
Project: zun   Author: openstack   File: a251f1f61217_create_capsule_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'capsule',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('capsule_version', sa.String(length=255), nullable=True),
        sa.Column('kind', sa.String(length=36), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('restart_policy', sa.String(length=255), nullable=True),
        sa.Column('host_selector', sa.String(length=255), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('status', sa.String(length=255), nullable=True),
        sa.Column('status_reason', sa.Text(), nullable=True),
        sa.Column('message', models.JSONEncodedDict(), nullable=True),
        sa.Column('spec', models.JSONEncodedDict(), nullable=True),
        sa.Column('cpu', sa.Float(), nullable=True),
        sa.Column('memory', sa.String(length=255), nullable=True),
        sa.Column('meta_name', sa.String(length=255), nullable=True),
        sa.Column('meta_labels', models.JSONEncodedList(), nullable=True),
        sa.Column('containers_uuids', models.JSONEncodedList(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
    ) 
Example 18
Project: zun   Author: openstack   File: a9a92eebd9a8_create_table_zun_service.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'zun_service',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('report_count', sa.Integer(), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=True),
        sa.Column('binary', sa.String(length=255), nullable=True),
        sa.Column('disabled', sa.Boolean(), nullable=True),
        sa.Column('disabled_reason', sa.String(length=255), nullable=True),
        sa.Column('last_seen_up', sa.DateTime(), nullable=True),
        sa.Column('forced_down', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('host', 'binary',
                            name='uniq_zun_service0host0binary')
    ) 
Example 19
Project: xiaodi   Author: shenaishiren   File: mysql.py    (license) View Source Project 6 votes vote down vote up
def _init_cls(cls):
    setattr(cls, '__tablename__', cls.__name__)
    setattr(cls, 'id', Column(Integer, primary_key=True, autoincrement=True))
    for _str in getattr(cls, 'stringV', []):
        setattr(cls, _str, Column(String(DB_STRING_LENGTH)))
    for _int in getattr(cls, 'integerV', []):
        setattr(cls, _int, Column(Integer))
    for _bool in getattr(cls, 'boolV', []):
        setattr(cls, _bool, Column(Boolean))
    for _float in getattr(cls, 'floatV', []):
        setattr(cls, _float, Column(Float))
    for _time in getattr(cls, 'timeV', []):
        setattr(cls, _time, Column(DateTime, default=datetime.utcnow))
    for key, value in getattr(cls, 'foreignKeyV', {}).iteritems():
        setattr(cls, key, Column(Integer, ForeignKey(value), primary_key=True))
    setattr(cls, 'to_json', _convert_attr_to_dict) 
Example 20
Project: retrospective-bot   Author: bayesimpact   File: 574083c098fc_create_retrospective_items_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table('sprints',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_name', sa.Unicode(), nullable=True),
        sa.Column('creation_date', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'))

    op.create_table('retrospective_items',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('sprint_id', sa.Integer(), nullable=False),
        sa.Column('category', sa.Unicode(), nullable=True),
        sa.Column('text', sa.Unicode(), nullable=True),
        sa.Column('user_name', sa.Unicode(), nullable=True),
        sa.Column('creation_date', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_retrospective_items'), 'retrospective_items', ['sprint_id', 'category'], unique=False) 
Example 21
Project: flasky   Author: RoseOu   File: 51f5ccfba190_comments.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('ix_comments_timestamp', 'comments', ['timestamp'], unique=False)
    ### end Alembic commands ### 
Example 22
Project: kuberdock-platform   Author: cloudlinux   File: 53489a9c1e2d_usage_ip_states_and_pd_states.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table('pd_states',
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('pd_name', sa.String(), nullable=False),
                    sa.Column('size', sa.Integer(), nullable=False),
                    sa.Column('start_time', sa.DateTime(), nullable=False),
                    sa.Column('end_time', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(['user_id'], ['users.id']),
                    sa.PrimaryKeyConstraint('start_time'))
    op.create_table('ip_states',
                    sa.Column('pod_id', postgresql.UUID(), nullable=False),
                    sa.Column('ip_address', sa.BigInteger(), nullable=False),
                    sa.Column('start_time', sa.DateTime(), nullable=False),
                    sa.Column('end_time', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(['pod_id'], ['pods.id']),
                    sa.PrimaryKeyConstraint('pod_id', 'start_time')) 
Example 23
Project: mensa-tracker   Author: annyanich   File: db2754bfb7bc_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('social_id', sa.String(length=64), nullable=False),
    sa.Column('nickname', sa.String(length=256), nullable=False),
    sa.Column('email', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('social_id')
    )
    op.create_table('searches',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('search_terms', sa.String(length=64), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 24
Project: mensa-tracker   Author: annyanich   File: a94bc6277195_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('social_id', sa.String(length=64), nullable=False),
    sa.Column('nickname', sa.String(length=64), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('social_id')
    )
    op.create_table('searches',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('search_terms', sa.String(length=64), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 25
Project: flask-celery3-boilerplate   Author: sdg32   File: 8c368650ca58_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('schedule_info',
    sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
    sa.Column('last_changed_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('schedule_meta',
    sa.Column('parent_id', sa.Integer(), nullable=False),
    sa.Column('last_run_at', sa.DateTime(), nullable=True),
    sa.Column('total_run_count', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['parent_id'], ['schedule_task.id'], ),
    sa.PrimaryKeyConstraint('parent_id')
    )
    with op.batch_alter_table('schedule_task') as batch_op:
        batch_op.drop_column('total_run_count')
        batch_op.drop_column('last_run_at')
    # ### end Alembic commands ### 
Example 26
Project: coverage2sql   Author: openstack   File: 52dfb338f74e_add_coverages_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    migration_context = context.get_context()
    if migration_context.dialect.name == 'sqlite':
        id_type = sa.Integer
    else:
        id_type = sa.BigInteger

    op.create_table('coverages',
                    sa.Column('id', id_type, autoincrement=True,
                              primary_key=True),
                    sa.Column('project_name', sa.String(256), nullable=False),
                    sa.Column('coverage_rate', sa.Float()),
                    sa.Column('report_time', sa.DateTime()),
                    sa.Column('report_time_microsecond', sa.Integer(),
                              default=0),
                    mysql_engine='InnoDB')
    op.create_index('ix_project_name', 'coverages', ['project_name']) 
Example 27
Project: ml-annotate   Author: planbrothers   File: 186247cd152e_add_user_and_userproblem.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
    sa.Column('username', sa.Unicode(length=255), nullable=False),
    sa.Column('password', sqlalchemy_utils.types.password.PasswordType(), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('is_superuser', sa.Boolean(), server_default='FALSE', nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('user_problem',
    sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
    sa.Column('problem_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
    sa.Column('user_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
    sa.ForeignKeyConstraint(['problem_id'], ['problem.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_problem_user_id'), 'user_problem', ['user_id'], unique=False)
    # ### end Alembic commands ### 
Example 28
Project: bilean   Author: openstack   File: 002_add_job_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade(migrate_engine):
    meta = sqlalchemy.MetaData()
    meta.bind = migrate_engine

    job = sqlalchemy.Table(
        'job', meta,
        sqlalchemy.Column('id', sqlalchemy.String(50),
                          primary_key=True, nullable=False),
        sqlalchemy.Column('scheduler_id', sqlalchemy.String(36),
                          nullable=False),
        sqlalchemy.Column('job_type', sqlalchemy.String(10),
                          nullable=False),
        sqlalchemy.Column('parameters', types.Dict),
        sqlalchemy.Column('created_at', sqlalchemy.DateTime),
        sqlalchemy.Column('updated_at', sqlalchemy.DateTime),
        mysql_engine='InnoDB',
        mysql_charset='utf8'
    )

    try:
        job.create()
    except Exception:
        LOG.error("Table |%s| not created!", repr(job))
        raise 
Example 29
Project: chihu   Author: yelongyu   File: 10aa37389b60_add_comments_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    op.alter_column(u'statistic_visitor', 'referred',
               existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
               nullable=True,
               existing_server_default=sa.text(u"''"))
    ### end Alembic commands ### 
Example 30
Project: chihu   Author: yelongyu   File: 8d684695a2ec_add_statistic_visitor_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('statistic_visitor',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('last_count', sa.DateTime(), nullable=True),
    sa.Column('referred', sa.String(length=128), nullable=False),
    sa.Column('agent', sa.String(length=64), nullable=True),
    sa.Column('platform', sa.String(length=64), nullable=True),
    sa.Column('version', sa.String(length=64), nullable=True),
    sa.Column('ip', sa.String(length=64), nullable=True),
    sa.Column('hits', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id', 'referred'),
    sa.UniqueConstraint('id'),
    sa.UniqueConstraint('referred')
    )
    op.create_index(op.f('ix_statistic_visitor_last_count'), 'statistic_visitor', ['last_count'], unique=False)
    ### end Alembic commands ### 
Example 31
Project: chihu   Author: yelongyu   File: 22d850799214_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('machine_statistic',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('type', sa.String(length=64), nullable=True),
    sa.Column('timestamp', sa.String(length=64), nullable=True),
    sa.Column('userid', sa.String(length=64), nullable=True),
    sa.Column('netcode', sa.String(length=64), nullable=True),
    sa.Column('login_time', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('id')
    )
    op.create_index(op.f('ix_machine_statistic_login_time'), 'machine_statistic', ['login_time'], unique=False)
    op.alter_column(u'statistic_visitor', 'referred',
               existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
               nullable=True,
               existing_server_default=sa.text(u"''"))
    ### end Alembic commands ### 
Example 32
Project: heutagogy-backend   Author: heutagogy   File: 797321279ea1_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=255), nullable=False),
    sa.Column('password', sa.String(), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=True),
    sa.Column('confirmed_at', sa.DateTime(), nullable=True),
    sa.Column('is_active', sa.Boolean(), server_default='0', nullable=False),
    sa.Column('first_name', sa.String(length=255), server_default='', nullable=False),
    sa.Column('last_name', sa.String(length=255), server_default='', nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('bookmark',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=False),
    sa.Column('url', sa.String(), nullable=False),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('read', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['user'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    ) 
Example 33
Project: Adventure-Insecure   Author: colinnewell   File: 7b0843b4944f_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('order_header',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('date_modified', sa.DateTime(), nullable=True),
    sa.Column('title', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('order_line',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('date_modified', sa.DateTime(), nullable=True),
    sa.Column('request', sa.Text(), nullable=False),
    sa.Column('order_id', sa.Integer(), nullable=True),
    sa.Column('order_for', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['order_for'], ['users.id'], ),
    sa.ForeignKeyConstraint(['order_id'], ['order_header.id'], name='order_id_fkey'),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example 34
Project: Adventure-Insecure   Author: colinnewell   File: 24bb227a82fa_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    t = op.create_table('office_numbers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('date_modified', sa.DateTime(), nullable=True),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('number_prefix', sa.String(length=128), nullable=False),
    sa.Column('main_number', sa.String(length=128), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.bulk_insert(t, [
        {
            'name': 'Main Office',
            'number_prefix': '555-1',
            'main_number': '555-13211-3221',
        },
        {
            'name': 'Babel Office',
            'number_prefix': '555-2',
            'main_number': '555-21111-3221',
        },
        {
            'name': 'Office Minnows',
            'number_prefix': '555-9',
            'main_number': '555-99911-3221',
        },
    ])
    ### end Alembic commands ### 
Example 35
Project: picmeup   Author: zhonghcc   File: 144639404d09_02_create_collection.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'collections',
        sa.Column('id',sa.Integer,primary_key=True,autoincrement=True),
        sa.Column('name',sa.String(255), nullable=False,unique=True),

        sa.Column('created_time',sa.DateTime, default=datetime.now),
        sa.Column('updated_time',sa.DateTime, default=datetime.now),

        sa.Column('author_id',sa.Integer,nullable=True),
        sa.Column('status',sa.Integer, nullable=False),
        sa.Column('order',sa.Integer,nullable=True,default=0)
    )
    op.create_table(
        'collection_items',
        sa.Column('id',sa.Integer,primary_key=True,autoincrement=True),
        sa.Column('collection_id',sa.Integer,nullable=True),
        sa.Column('article_id',sa.Integer,nullable=True),

        sa.Column('created_time',sa.DateTime, default=datetime.now),
        sa.Column('updated_time',sa.DateTime, default=datetime.now),

        sa.Column('status',sa.Integer, nullable=False),
        sa.Column('order',sa.Integer,nullable=True,default=0)
    ) 
Example 36
Project: picmeup   Author: zhonghcc   File: b5b843df7bcb_05_tag_and_collection.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.drop_column('tags','author_id')
    op.add_column('tags',sa.Column('user_id',sa.Integer,nullable=True,default=0))
    op.add_column('users',sa.Column('coin_num',sa.Integer,nullable=False,default=5))
    op.create_table(
            'coins',
            sa.Column('id',sa.Integer,primary_key=True,autoincrement=True),
            sa.Column('direction',sa.String(50),nullable=False,default=""),
            sa.Column('reason',sa.String(50),nullable=False,default=""),
            sa.Column('article_id',sa.Integer, nullable=True),
            sa.Column('user_id',sa.Integer, nullable=True),
            sa.Column('ip',sa.String(50), nullable=True),
            sa.Column('coin_num',sa.Integer, nullable=False,default=0),

            sa.Column('created_time',sa.DateTime, default=datetime.now),
            sa.Column('updated_time',sa.DateTime, default=datetime.now),

            sa.Column('status',sa.Integer, nullable=False),
    )
    pass 
Example 37
Project: town-council   Author: Data4Democracy   File: db_utils.py    (license) View Source Project 6 votes vote down vote up
def get_url_stage():

    _, metadata = setup_db()

    table = Table(
            'url_stage',
            metadata,
            Column('id', Integer, primary_key=True),
            Column('ocd_division_id', String),
            Column('event', String),
            Column('event_date', Date),
            Column('url', String),
            Column('url_hash', String),
            Column('category', String),
            Column('created_at', DateTime, default=datetime.datetime.now)
    )

    return table 
Example 38
Project: town-council   Author: Data4Democracy   File: db_utils.py    (license) View Source Project 6 votes vote down vote up
def get_url_stage_hist():

    _, metadata = setup_db()

    table = Table(
            'url_stage_hist',
            metadata,
            Column('id', Integer, primary_key=True),
            Column('event', String),
            Column('event_date', Date),
            Column('url', String),
            Column('url_hash', String),
            Column('category', String),
            Column('created_at', DateTime, default=datetime.datetime.now)
    )

    return table 
Example 39
Project: town-council   Author: Data4Democracy   File: db_utils.py    (license) View Source Project 6 votes vote down vote up
def get_document():
    _, metadata = setup_db()
    catalog = get_catalog()
    place = get_place()
    event = get_event()

    table = Table(
            'document',
            metadata,
            Column('id', Integer, primary_key=True),
            Column('place_id', Integer, ForeignKey(place.c.id),
                   nullable=False, index=True),
            Column('event_id', Integer, ForeignKey(event.c.id),
                   nullable=False, index=True),
            Column('catalog_id', Integer, ForeignKey(catalog.c.id),
                   nullable=True, index=True),
            Column('url', String),
            Column('url_hash', String),
            Column('media_type', String),
            Column('category', String),
            Column('created_at', DateTime, default=datetime.datetime.now)
    )

    return table 
Example 40
Project: town-council   Author: Data4Democracy   File: db_utils.py    (license) View Source Project 6 votes vote down vote up
def get_event():
    _, metadata = setup_db()
    place = get_place()

    table = Table(
        'event',
        metadata,
        Column('id', Integer, primary_key=True),
        Column('place_id', Integer, ForeignKey(place.c.id),
               nullable=False, index=True),
        Column('name', String),
        Column('scraped_datetime', DateTime, default=datetime.datetime.now),
        Column('record_date', Date),
        Column('source', String),
        Column('source_url', String),
        Column('meeting_type', String)
        )

    return table 
Example 41
Project: quark   Author: openstack   File: 26e984b48a0d_revise_security_group_rules.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # NOTE(mdietz): You can't change the datatype or remove columns,
    #               in SQLite, please see
    #               http://sqlite.org/lang_altertable.html
    op.drop_table(OLD_TABLE)
    op.create_table(
        NEW_TABLE,
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('group_id', sa.String(length=36), nullable=False),
        sa.Column('direction', sa.String(length=10), nullable=False),
        sa.Column('port_range_max', sa.Integer(), nullable=True),
        sa.Column('port_range_min', sa.Integer(), nullable=True),
        sa.Column('protocol', sa.Integer(), nullable=True),
        sa.Column("ethertype", type_=sa.Integer(), nullable=False),
        sa.Column('remote_group_id', sa.String(length=36), nullable=True),
        sa.Column("remote_ip_prefix", type_=sa.String(255)),
        sa.ForeignKeyConstraint(["remote_group_id"],
                                ["quark_security_groups.id"],
                                "fk_remote_group_id"),
        sa.ForeignKeyConstraint(['group_id'], ['quark_security_groups.id'], ),
        sa.PrimaryKeyConstraint('id'),
        mysql_engine="InnoDB") 
Example 42
Project: quark   Author: openstack   File: 26e984b48a0d_revise_security_group_rules.py    (license) View Source Project 6 votes vote down vote up
def downgrade():
    op.drop_table(NEW_TABLE)
    op.create_table(
        OLD_TABLE,
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('group_id', sa.String(length=36), nullable=False),
        sa.Column('direction', sa.String(length=10), nullable=False),
        sa.Column('ethertype', sa.String(length=4), nullable=False),
        sa.Column('port_range_max', sa.Integer(), nullable=True),
        sa.Column('port_range_min', sa.Integer(), nullable=True),
        sa.Column('protocol', sa.Integer(), nullable=True),
        sa.Column('remote_ip_prefix', sa.String(length=22), nullable=True),
        sa.Column('remote_group_id', sa.String(length=36), nullable=True),
        sa.ForeignKeyConstraint(['group_id'], ['quark_security_groups.id'], ),
        sa.PrimaryKeyConstraint('id'),
        mysql_engine='InnoDB') 
Example 43
Project: aiohttp_admin   Author: aio-libs   File: db_fixtures.py    (license) View Source Project 6 votes vote down vote up
def sa_table():
    choices = ['a', 'b', 'c']
    meta = sa.MetaData()
    post = sa.Table(
        'test_post', meta,
        sa.Column('id', sa.Integer, nullable=False),
        sa.Column('title', sa.String(200), nullable=False),
        sa.Column('category', sa.String(200), nullable=True),
        sa.Column('body', sa.Text, nullable=False),
        sa.Column('views', sa.Integer, nullable=False),
        sa.Column('average_note', sa.Float, nullable=False),
        # sa.Column('pictures', postgresql.JSON, server_default='{}'),
        sa.Column('published_at', sa.DateTime, nullable=False),
        # sa.Column('tags', postgresql.ARRAY(sa.Integer), server_default='{}'),
        sa.Column('status',
                  sa.Enum(*choices, name="enum_name", native_enum=False),
                  server_default="a", nullable=False),
        sa.Column('visible', sa.Boolean, nullable=False),

        # Indexes #
        sa.PrimaryKeyConstraint('id', name='post_id_pkey'))
    return post 
Example 44
Project: aiohttp_admin   Author: aio-libs   File: db_fixtures.py    (license) View Source Project 6 votes vote down vote up
def document_schema():
    choices = ['a', 'b', 'c']
    schema = t.Dict({
        t.Key('_id'): MongoId,
        t.Key('title'): t.String(max_length=200),
        t.Key('category'): t.String(max_length=200),
        t.Key('body'): t.String,
        t.Key('views'): t.Int,
        t.Key('average_note'): t.Float,
        # t.Key('pictures'): t.Dict({}).allow_extra('*'),
        t.Key('published_at'): DateTime,
        # t.Key('tags'): t.List(t.Int),
        t.Key('status'): t.Enum(*choices),
        t.Key('visible'): t.StrBool,
    })
    return schema 
Example 45
Project: vk-channelify   Author: reo7sp   File: f5f69376d382_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('channels',
    sa.Column('channel_id', sa.String(), nullable=False),
    sa.Column('vk_group_id', sa.String(), nullable=False),
    sa.Column('last_vk_post_id', sa.Integer(), server_default='0', nullable=False),
    sa.Column('owner_id', sa.String(), nullable=True),
    sa.Column('owner_username', sa.String(), nullable=True),
    sa.Column('hashtag_filter', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('channel_id')
    )
    op.create_table('disabled_channels',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('vk_group_id', sa.String(), nullable=True),
    sa.Column('last_vk_post_id', sa.Integer(), nullable=True),
    sa.Column('owner_id', sa.String(), nullable=True),
    sa.Column('owner_username', sa.String(), nullable=True),
    sa.Column('hashtag_filter', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
Example 46
Project: floranet   Author: Fluent-networks   File: f966d7f314d5_create_application_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'applications',
        sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
        sa.Column('appeui', sa.Numeric, nullable=False, unique=True),
        sa.Column('name', sa.String, nullable=True),
        sa.Column('domain', sa.String, nullable=True),
        sa.Column('appnonce', sa.Integer, nullable=False),
        sa.Column('appkey', sa.Numeric, nullable=False),
        sa.Column('fport', sa.Integer, nullable=False),        
        sa.Column('modname', sa.String, nullable=False),
        sa.Column('proto', sa.String, nullable=False),
        sa.Column('listen', sa.String, nullable=False),
        sa.Column('port', sa.Integer, nullable=False),
        sa.Column('created', sa.DateTime(timezone=True), nullable=False),
        sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
        ) 
Example 47
Project: floranet   Author: Fluent-networks   File: 03fabc9f542b_create_gateways_table_add_devnonce.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'gateways',
        sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
        sa.Column('host', INET, nullable=False, unique=True),
        sa.Column('name', sa.String, nullable=True),
        sa.Column('enabled', sa.Boolean, nullable=False, default=True),
        sa.Column('eui', sa.Numeric, nullable=False, unique=True),
        sa.Column('power', sa.Integer, nullable=False),
        sa.Column('port', sa.String, nullable=True),
        sa.Column('latitude', sa.Float, nullable=True),
        sa.Column('longitude', sa.Float, nullable=True),
        sa.Column('created', sa.DateTime(timezone=True), nullable=False),
        sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
        )
    op.add_column('devices',
        sa.Column('devnonce', sa.dialects.postgresql.ARRAY(sa.Integer()))) 
Example 48
Project: floranet   Author: Fluent-networks   File: 5f0ed1bab7fa_create_config_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'config',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String, nullable=False),
        sa.Column('listen', INET, nullable=False),
        sa.Column('port', sa.Integer, nullable=False),
        sa.Column('webport', sa.Integer, nullable=False),
        sa.Column('apitoken', sa.String, nullable=False),
        sa.Column('freqband', sa.String, nullable=False),
        sa.Column('netid', sa.Integer, nullable=False),
        sa.Column('duplicateperiod', sa.Integer, nullable=False),
        sa.Column('fcrelaxed', sa.Boolean, nullable=False),
        sa.Column('otaastart', sa.Integer, nullable=False),
        sa.Column('otaaend', sa.Integer, nullable=False),
        sa.Column('macqueueing', sa.Boolean, nullable=False),
        sa.Column('macqueuelimit', sa.Integer, nullable=False),
        sa.Column('adrenable', sa.Boolean, nullable=False),
        sa.Column('adrmargin', sa.Float, nullable=False),
        sa.Column('adrcycletime', sa.Integer, nullable=False),
        sa.Column('adrmessagetime', sa.Integer, nullable=False),
        sa.Column('created', sa.DateTime(timezone=True), nullable=False),
        sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
        ) 
Example 49
Project: floranet   Author: Fluent-networks   File: e7ff8a1b22fd_create_device_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'devices',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('deveui', sa.Numeric, nullable=True),
        sa.Column('devaddr', sa.Integer, nullable=False),
        sa.Column('devclass', sa.String(length=1), nullable=False),
        sa.Column('appeui', sa.Numeric, nullable=False),
        sa.Column('nwkskey', sa.Numeric, nullable=False),
        sa.Column('appskey', sa.Numeric, nullable=False),
        sa.Column('tx_chan', sa.Integer, nullable=True),
        sa.Column('tx_datr', sa.String, nullable=True),
        sa.Column('gw_addr', sa.String, nullable=True),
        sa.Column('time', sa.DateTime(timezone=True), nullable=True),
        sa.Column('tmst', sa.Numeric, nullable=True),
        sa.Column('fcntup', sa.Integer, server_default="0", nullable=False),
        sa.Column('fcntdown', sa.Integer, server_default="0", nullable=False),
        ) 
Example 50
Project: zual   Author: ninadmhatre   File: sqlastorage.py    (license) View Source Project 6 votes vote down vote up
def _create_post_table(self):
        """
        Creates the table to store the blog posts.
        :return:
        """
        with self._engine.begin() as conn:
            post_table_name = self._table_name("post")
            if not conn.dialect.has_table(conn, post_table_name):
                self._post_table = sqla.Table(
                    post_table_name, self._metadata,
                    sqla.Column("id", sqla.Integer, primary_key=True),
                    sqla.Column("title", sqla.String(256)),
                    sqla.Column("text", sqla.Text),
                    sqla.Column("post_date", sqla.DateTime),
                    sqla.Column("last_modified_date", sqla.DateTime),
                    # if 1 then make it a draft
                    sqla.Column("draft", sqla.SmallInteger, default=0)

                )
                self._logger.debug("Created table with table name %s" %
                                   post_table_name)
            else:
                self._post_table = self._metadata.tables[post_table_name]
                self._logger.debug("Reflecting to table with table name %s" %
                                   post_table_name)