def upgrade(): op.create_table( "applications", sa.Column("id", sa.Integer, primary_key=True, index=True), sa.Column("name", sa.String(30), nullable=False, unique=True, index=True), sa.Column("real_name", sa.String(250), nullable=False), sa.Column("model", sa.Integer, nullable=False, default=1), sa.Column("description", sa.String(250), nullable=False), sa.Column("details", sa.String(5000), nullable=True), sa.Column("active", sa.Boolean, nullable=False, default=True), sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, default=datetime.now()), sa.Column("created_by", sa.Integer, sa.ForeignKey("users.id")), sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, default=datetime.now()), sa.Column("updated_by", sa.Integer, sa.ForeignKey("users.id"))) bind = op.get_bind() session = Session(bind=bind) session.execute( """ INSERT INTO applications (name, real_name, model, description, details, active, created_at, created_by, updated_at, updated_by) VALUES (:name, :real_name, :model, :description, :details, :active, :created_at, :created_by, :updated_at, :updated_by) """, { "name": "netflix", "real_name": "Netflix", "model": 1, "description": "Streaming movies, series, animes etc...", "details": "https://netflix.com.br", "active": True, "created_at": datetime.now(), "created_by": 1, "updated_at": datetime.now(), "updated_by": 1 }) session.execute( """ INSERT INTO applications (name, real_name, model, description, details, active, created_at, created_by, updated_at, updated_by) VALUES (:name, :real_name, :model, :description, :details, :active, :created_at, :created_by, :updated_at, :updated_by) """, { "name": "whats_app", "real_name": "Whats App", "model": 2, "description": "Sendind and receive instant messages, videos, gifs and docs", "details": "https://whatsapp.com.br", "active": True, "created_at": datetime.now(), "created_by": 2, "updated_at": datetime.now(), "updated_by": 2 }) session.execute( """ INSERT INTO applications (name, real_name, model, description, details, active, created_at, created_by, updated_at, updated_by) VALUES (:name, :real_name, :model, :description, :details, :active, :created_at, :created_by, :updated_at, :updated_by) """, { "name": "microsoft_office", "real_name": "Microsoft Office", "model": 2, "description": "Docs, sheets, presents, email etc...", "details": "https://msoffice365.com.br", "active": True, "created_at": datetime.now(), "created_by": 3, "updated_at": datetime.now(), "updated_by": 3 })
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table( 'laws', sa.Column('id', sa.Integer(), nullable=False), sa.Column('subject', sa.Text(), nullable=False), sa.Column('category', sa.String(length=256), nullable=False), sa.Column('body', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table('news', sa.Column('id', sa.Integer(), nullable=False), sa.Column('subject', sa.Text(), nullable=False), sa.Column('body', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.Text(), nullable=False), sa.Column('password2', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('username')) op.create_table( 'questions', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.Text(), nullable=False), sa.Column('approved', sa.Boolean(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('subject', sa.Text(), nullable=False), sa.Column('category', sa.String(length=256), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], deferrable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'answers', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('question_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['question_id'], ['questions.id'], deferrable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], deferrable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'contacts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('display_name', sa.Text(), nullable=True), sa.Column('remote_host', sa.String(length=15), nullable=True), sa.Column('telephone', sa.Text(), nullable=True), sa.Column('qq', sa.Text(), nullable=True), sa.Column('email', sa.Text(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('question_id', sa.Integer(), nullable=True), sa.Column('answer_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('wechat', sa.Text(), nullable=True), sa.Column('address', sa.Text(), nullable=True), sa.Column('postcode', sa.Text(), nullable=True), sa.ForeignKeyConstraint(['answer_id'], ['answers.id'], deferrable=True), sa.ForeignKeyConstraint(['question_id'], ['questions.id'], deferrable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], deferrable=True), sa.PrimaryKeyConstraint('id'))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( "datasets", sa.Column( "created_timestamp", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False, ), sa.Column("modified_timestamp", sa.DateTime(timezone=True), nullable=True), sa.Column("id", simpleml.orm.sqlalchemy_types.GUID(), nullable=False), sa.Column("hash", sa.BIGINT(), nullable=False), sa.Column("registered_name", sa.String(), nullable=False), sa.Column("author", sa.String(), nullable=False), sa.Column("project", sa.String(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("version", sa.Integer(), nullable=False), sa.Column("version_description", sa.String(), nullable=True), sa.Column("has_external_files", sa.Boolean(), nullable=True), sa.Column("filepaths", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("metadata", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("pipeline_id", simpleml.orm.sqlalchemy_types.GUID(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("name", "version", name="dataset_name_version_unique"), ) op.create_index("dataset_name_index", "datasets", ["name"], unique=False) op.create_table( "metrics", sa.Column( "created_timestamp", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False, ), sa.Column("modified_timestamp", sa.DateTime(timezone=True), nullable=True), sa.Column("id", simpleml.orm.sqlalchemy_types.GUID(), nullable=False), sa.Column("hash", sa.BIGINT(), nullable=False), sa.Column("registered_name", sa.String(), nullable=False), sa.Column("author", sa.String(), nullable=False), sa.Column("project", sa.String(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("version", sa.Integer(), nullable=False), sa.Column("version_description", sa.String(), nullable=True), sa.Column("has_external_files", sa.Boolean(), nullable=True), sa.Column("filepaths", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("metadata", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("values", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=False), sa.Column("model_id", simpleml.orm.sqlalchemy_types.GUID(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("name", "model_id", "version", name="metric_name_model_version_unique"), ) op.create_index("metric_name_index", "metrics", ["name"], unique=False) op.create_table( "models", sa.Column( "created_timestamp", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False, ), sa.Column("modified_timestamp", sa.DateTime(timezone=True), nullable=True), sa.Column("id", simpleml.orm.sqlalchemy_types.GUID(), nullable=False), sa.Column("hash", sa.BIGINT(), nullable=False), sa.Column("registered_name", sa.String(), nullable=False), sa.Column("author", sa.String(), nullable=False), sa.Column("project", sa.String(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("version", sa.Integer(), nullable=False), sa.Column("version_description", sa.String(), nullable=True), sa.Column("has_external_files", sa.Boolean(), nullable=True), sa.Column("filepaths", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("metadata", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("params", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("feature_metadata", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("pipeline_id", simpleml.orm.sqlalchemy_types.GUID(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("name", "version", name="model_name_version_unique"), ) op.create_index("model_name_index", "models", ["name"], unique=False) op.create_table( "pipelines", sa.Column( "created_timestamp", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False, ), sa.Column("modified_timestamp", sa.DateTime(timezone=True), nullable=True), sa.Column("id", simpleml.orm.sqlalchemy_types.GUID(), nullable=False), sa.Column("hash", sa.BIGINT(), nullable=False), sa.Column("registered_name", sa.String(), nullable=False), sa.Column("author", sa.String(), nullable=False), sa.Column("project", sa.String(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("version", sa.Integer(), nullable=False), sa.Column("version_description", sa.String(), nullable=True), sa.Column("has_external_files", sa.Boolean(), nullable=True), sa.Column("filepaths", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("metadata", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("params", simpleml.orm.sqlalchemy_types.MutableJSON, nullable=True), sa.Column("dataset_id", simpleml.orm.sqlalchemy_types.GUID(), nullable=True), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("name", "version", name="pipeline_name_version_unique"), ) op.create_index("pipeline_name_index", "pipelines", ["name"], unique=False) # Use "batch" operations to support sqlite restrictions with op.batch_alter_table("datasets") as batch_op: batch_op.create_foreign_key( "datasets_pipeline_id_fkey", "pipelines", ["pipeline_id"], ["id"], ondelete="CASCADE", ) with op.batch_alter_table("pipelines") as batch_op: batch_op.create_foreign_key( "pipelines_dataset_id_fkey", "datasets", ["dataset_id"], ["id"], ondelete="CASCADE", ) with op.batch_alter_table("models") as batch_op: batch_op.create_foreign_key( "models_pipeline_id_fkey", "pipelines", ["pipeline_id"], ["id"], ondelete="CASCADE", ) with op.batch_alter_table("metrics") as batch_op: batch_op.create_foreign_key("metrics_model_id_fkey", "models", ["model_id"], ["id"], ondelete="CASCADE")
def upgrade(): for table in tables: op.add_column(table, sa.Column(u'created_at', sa.DateTime(), nullable=True)) op.add_column(table, sa.Column(u'updated_at', sa.DateTime(), nullable=True))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=64), nullable=True), sa.Column('default', sa.Boolean(), nullable=True), sa.Column('permissions', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name')) op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False) op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.String(length=64), nullable=True), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.Column('password_hash', sa.String(length=128), nullable=True), sa.Column('confirmed', sa.Boolean(), nullable=True), sa.Column('name', sa.String(length=64), nullable=True), sa.Column('location', sa.String(length=64), nullable=True), sa.Column('about_me', sa.Text(), nullable=True), sa.Column('member_since', sa.DateTime(), nullable=True), sa.Column('last_seen', sa.DateTime(), nullable=True), sa.Column('avatar_hash', sa.String(length=32), nullable=True), sa.ForeignKeyConstraint( ['role_id'], ['roles.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True) op.create_table('follows', sa.Column('follower_id', sa.Integer(), nullable=False), sa.Column('followed_id', sa.Integer(), nullable=False), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['followed_id'], ['users.id'], ), sa.ForeignKeyConstraint( ['follower_id'], ['users.id'], ), sa.PrimaryKeyConstraint('follower_id', 'followed_id')) op.create_table('posts', 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('author_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['author_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_posts_timestamp'), 'posts', ['timestamp'], unique=False) 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)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('answer', sa.Column('create_time', sa.DateTime(), nullable=True))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('user', sa.Column('about_me', sa.String(length=140), nullable=True)) op.add_column('user', sa.Column('last_seen', sa.DateTime(), nullable=True))
def upgrade(): op.create_table('device', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=False), sa.Column('serial_number', sa.String(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('serial_number') ) op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(), nullable=False), sa.Column('password', sa.String(), nullable=False), sa.Column('active', sa.Boolean(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('username') ) op.create_table('logentry', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('device_id', sa.Integer(), nullable=False), sa.Column('date_time', sa.DateTime(), nullable=False), sa.Column('duration', sa.Interval(), nullable=True), sa.Column('distance', sa.Integer(), nullable=True), sa.Column('activity', sa.String(), nullable=True), sa.Column('activity_type', sa.Integer(), nullable=True), sa.Column('log_item_count', sa.Integer(), nullable=True), sa.Column('ascent', sa.Integer(), nullable=True), sa.Column('descent', sa.Integer(), nullable=True), sa.Column('ascent_time', sa.Interval(), nullable=True), sa.Column('descent_time', sa.Interval(), nullable=True), sa.Column('recovery_time', sa.Interval(), nullable=True), sa.Column('speed_avg', sa.Float(), nullable=True), sa.Column('speed_max', sa.Float(), nullable=True), sa.Column('speed_max_time', sa.Interval(), nullable=True), sa.Column('hr_avg', sa.Float(), nullable=True), sa.Column('hr_min', sa.Float(), nullable=True), sa.Column('hr_max', sa.Float(), nullable=True), sa.Column('hr_min_time', sa.Interval(), nullable=True), sa.Column('hr_max_time', sa.Interval(), nullable=True), sa.Column('peak_training_effect', sa.Float(), nullable=True), sa.Column('energy', sa.Float(), nullable=True), sa.Column('cadence_avg', sa.Float(), nullable=True), sa.Column('cadence_max', sa.Float(), nullable=True), sa.Column('cadence_max_time', sa.Interval(), nullable=True), sa.Column('altitude_min', sa.Integer(), nullable=True), sa.Column('altitude_max', sa.Integer(), nullable=True), sa.Column('altitude_min_time', sa.Interval(), nullable=True), sa.Column('altitude_max_time', sa.Interval(), nullable=True), sa.Column('temperature_min', sa.Float(), nullable=True), sa.Column('temperature_max', sa.Float(), nullable=True), sa.Column('temperature_min_time', sa.Float(), nullable=True), sa.Column('temperature_max_time', sa.Float(), nullable=True), sa.Column('time_to_first_fix', sa.Integer(), nullable=True), sa.Column('battery_charge_at_start', sa.Integer(), nullable=True), sa.Column('battery_charge', sa.Integer(), nullable=True), sa.Column('distance_before_calibration_change', sa.Integer(), nullable=True), sa.Column('pool_length', sa.Integer(), nullable=True), sa.Column('device_info_sw', sa.String(), nullable=True), sa.Column('device_info_hw', sa.String(), nullable=True), sa.Column('device_info_bsl', sa.String(), nullable=True), sa.Column('device_info_sw_build_date_time', sa.DateTime(), nullable=True), sa.Column('source', sa.String(), nullable=True), sa.ForeignKeyConstraint(['device_id'], ['device.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index('logentry_user_id_date_time_idx', 'logentry', ['user_id', 'date_time'], unique=False) op.create_table('sample', sa.Column('id', sa.Integer(), nullable=False), sa.Column('log_entry_id', sa.Integer(), nullable=False), sa.Column('sample_type', sa.String(), nullable=True), sa.Column('time', sa.Interval(), nullable=True), sa.Column('utc', sa.DateTime(), nullable=True), sa.Column('distance', sa.Float(), nullable=True), sa.Column('speed', sa.Float(), nullable=True), sa.Column('temperature', sa.Float(), nullable=True), sa.Column('hr', sa.Float(), nullable=True), sa.Column('energy_consumption', sa.Float(), nullable=True), sa.Column('vertical_speed', sa.Float(), nullable=True), sa.Column('sea_level_pressure', sa.Float(), nullable=True), sa.Column('gps_altitude', sa.Float(), nullable=True), sa.Column('gps_heading', sa.Float(), nullable=True), sa.Column('gps_speed', sa.Float(), nullable=True), sa.Column('gps_hdop', sa.Float(), nullable=True), sa.Column('number_of_satellites', sa.Integer(), nullable=True), sa.Column('latitude', sa.Float(), nullable=True), sa.Column('longitude', sa.Float(), nullable=True), sa.Column('altitude', sa.Integer(), nullable=True), sa.Column('ehpe', sa.Float(), nullable=True), sa.Column('cadence', sa.Float(), nullable=True), sa.Column('nav_type', sa.Integer(), nullable=True), sa.Column('nav_valid', sa.String(), nullable=True), sa.Column('nav_type_explanation', sa.String(), nullable=True), sa.Column('events', sa.String(), nullable=True), sa.Column('satellites', sa.String(), nullable=True), sa.Column('apps_data', sa.String(), nullable=True), sa.ForeignKeyConstraint(['log_entry_id'], ['logentry.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index('sample_log_entry_id_time_idx', 'sample', ['log_entry_id', 'time'], unique=False)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('users', schema=None) as batch_op: batch_op.add_column(sa.Column('last_recived_comments_read_time', sa.DateTime(), nullable=True))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('group', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_group_timestamp'), 'group', ['timestamp'], unique=False) op.create_table( 'user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=64), nullable=True), sa.Column('email', sa.String(length=120), nullable=True), sa.Column('password_hash', sa.String(length=128), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True) op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True) op.create_table('group_identifier', sa.Column('group_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['group_id'], ['group.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['user.id'], )) op.create_table('post', sa.Column('id', sa.Integer(), nullable=False), sa.Column('body', sa.String(length=140), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_post_timestamp'), 'post', ['timestamp'], unique=False) op.create_table('topic', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('title', sa.String(length=64), nullable=True), sa.Column('body', sa.String(length=512), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.Column('group_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['group_id'], ['group.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_topic_timestamp'), 'topic', ['timestamp'], unique=False) op.create_table('comment', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('topic_id', sa.Integer(), nullable=True), sa.Column('body', sa.String(length=512), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['topic_id'], ['topic.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_comment_timestamp'), 'comment', ['timestamp'], unique=False)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('product', sa.Column('timestamp', sa.DateTime(), nullable=True)) op.create_index(op.f('ix_product_timestamp'), 'product', ['timestamp'], unique=False)
class Badge(db.Model, SearchableMixin, SerializableMixin): """Release from GitHub""" __tablename__ = 'Badge' __searchable__ = ['name', 'value'] __serializable__ = [ 'id', 'hash', 'name', 'style', 'colorhex', 'issued_at', 'assigner_id', 'repository_id' ] # TODO: add styles styles = frozenset(('flat', )) #: Unique identifier of the page id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) #: URL slug for the page hash = sqlalchemy.Column(sqlalchemy.String(100), unique=True) #: Title of the page name = sqlalchemy.Column(sqlalchemy.UnicodeText) #: HTML page contents value = sqlalchemy.Column(sqlalchemy.UnicodeText) #: HTML page contents style = sqlalchemy.Column(sqlalchemy.String(100)) #: HTML page contents colorhex = sqlalchemy.Column(sqlalchemy.String(7)) #: Timestamp when assigned issued_at = sqlalchemy.Column(sqlalchemy.DateTime(), default=datetime.datetime.utcnow) #: ID of user's account within app assigner_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey('UserAccount.id')) #: User's account within app assigner = sqlalchemy.orm.relationship('UserAccount', back_populates='assigned_badges') #: ID of the repository where release belongs to repository_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey('Repository.id')) #: Repository where release belongs to repository = sqlalchemy.orm.relationship('Repository', back_populates='badges') def __init__(self, name, value, style, colorhex): self.name = name self.value = value self.style = style self.colorhex = colorhex def __repr__(self): """Standard string representation of DB object :return: Unique string representation :rtype: str """ return '<Badge {} (#{})>'.format(self.hash, self.id) @property def is_valid(self): if not isinstance(self.name, str) or len(self.name) < 1: print(f'name:{self.name}') return False if not isinstance(self.value, str) or len(self.value) < 1: print(f'value:{self.value}') return False if self.style not in self.styles: print(f'style:{self.style}') print(self.styles) return False if re.match('^#[0-9a-fA-F]{6}$', self.colorhex) is None: print(f'colorhex:{self.colorhex}') return False return True @staticmethod def generate_random_hash(): return hashlib.md5(os.urandom(32)).hexdigest()
def upgrade(): op.create_table('franchises', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=50), nullable=True), sa.Column('status', sa.String(length=20), nullable=True), sa.Column('colors', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table('seasons', sa.Column('id', sa.Integer(), nullable=False), sa.Column('number', sa.String(length=2), nullable=True), sa.Column('name', sa.String(length=50), nullable=True), sa.Column('first_week_date', sa.Date(), nullable=True), sa.Column('last_week_date', sa.Date(), nullable=True), sa.Column('gm_league_id', sa.Integer(), nullable=True), sa.Column('gm_division_id', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'games', sa.Column('id', sa.Integer(), nullable=False), sa.Column('season_id', sa.Integer(), nullable=True), sa.Column('season_stage', sa.String(length=20), server_default='regular', nullable=True), sa.Column('starts_at', sa.DateTime(), nullable=True), sa.Column('score_status', sa.Integer(), nullable=True), sa.Column('score_status_comments', sa.String(length=255), nullable=True), sa.Column('notes', sa.Text(), nullable=True), sa.ForeignKeyConstraint( ['season_id'], ['seasons.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'teams', sa.Column('id', sa.String(length=15), nullable=False), sa.Column('season_id', sa.Integer(), nullable=True), sa.Column('franchise_id', sa.Integer(), nullable=True), sa.Column('name', sa.String(length=50), nullable=True), sa.Column('regular_rank', sa.Integer(), nullable=True), sa.Column('regular_played', sa.Integer(), nullable=True), sa.Column('regular_won', sa.Integer(), nullable=True), sa.Column('regular_lost', sa.Integer(), nullable=True), sa.Column('regular_drawn', sa.Integer(), nullable=True), sa.Column('regular_forfeits_for', sa.Integer(), nullable=True), sa.Column('regular_forfeits_against', sa.Integer(), nullable=True), sa.Column('regular_score_for', sa.Integer(), nullable=True), sa.Column('regular_score_against', sa.Integer(), nullable=True), sa.Column('regular_score_difference', sa.Integer(), nullable=True), sa.Column('regular_bonus_points', sa.Integer(), nullable=True), sa.Column('regular_points', sa.Integer(), nullable=True), sa.Column('finals_rank', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['franchise_id'], ['franchises.id'], ), sa.ForeignKeyConstraint( ['season_id'], ['seasons.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('game_sides', sa.Column('id', sa.Integer(), nullable=False), sa.Column('team_id', sa.String(length=15), nullable=False), sa.Column('score', sa.Integer(), nullable=True), sa.Column('points', sa.Integer(), nullable=True), sa.Column('outcome', sa.String(length=5), nullable=True), sa.Column('game_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['game_id'], ['games.id'], ), sa.ForeignKeyConstraint( ['team_id'], ['teams.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): op.create_table('organization', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('userid', sa.Unicode(length=22), nullable=False), sa.Column('status', sa.Integer(), nullable=False), sa.Column('name', sa.Unicode(length=250), nullable=False), sa.Column('title', sa.Unicode(length=250), nullable=False), sa.Column('details', JsonDict(), server_default='{}', nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name'), sa.UniqueConstraint('userid') ) op.create_table('user', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('status', sa.Integer(), nullable=False), sa.Column('lastuser_token_scope', sa.Unicode(length=250), nullable=True), sa.Column('lastuser_token_type', sa.Unicode(length=250), nullable=True), sa.Column('userinfo', coaster.sqlalchemy.JsonDict(), nullable=True), sa.Column('email', sa.Unicode(length=80), nullable=True), sa.Column('lastuser_token', sa.String(length=22), nullable=True), sa.Column('username', sa.Unicode(length=80), nullable=True), sa.Column('userid', sa.String(length=22), nullable=False), sa.Column('fullname', sa.Unicode(length=80), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('lastuser_token'), sa.UniqueConstraint('userid'), sa.UniqueConstraint('username') ) op.create_table('discount_policy', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('organization_id', sa.Integer(), nullable=False), sa.Column('discount_type', sa.Integer(), nullable=False), sa.Column('item_quantity_min', sa.Integer(), nullable=False), sa.Column('item_quantity_max', sa.Integer(), nullable=True), sa.Column('discount_code_base', sa.Unicode(length=20), nullable=True), sa.Column('percentage', sa.Integer(), nullable=False), sa.Column('name', sa.Unicode(length=250), nullable=False), sa.Column('title', sa.Unicode(length=250), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.CheckConstraint('item_quantity_min <= item_quantity_max', name='discount_policy_item_quantity_check'), sa.CheckConstraint('percentage > 0 and percentage <= 100', name='discount_policy_percentage_check'), sa.ForeignKeyConstraint(['organization_id'], ['organization.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('organization_id', 'name') ) op.create_table('item_collection', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('description_text', sa.UnicodeText(), nullable=False), sa.Column('description_html', sa.UnicodeText(), nullable=False), sa.Column('organization_id', sa.Integer(), nullable=False), sa.Column('name', sa.Unicode(length=250), nullable=False), sa.Column('title', sa.Unicode(length=250), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['organization_id'], ['organization.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('organization_id', 'name') ) op.create_table('category', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('item_collection_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('name', sa.Unicode(length=250), nullable=False), sa.Column('title', sa.Unicode(length=250), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.Column('seq', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['item_collection_id'], ['item_collection.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('item_collection_id', 'name'), sa.UniqueConstraint('item_collection_id', 'seq') ) op.create_table('customer_order', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('organization_id', sa.Integer(), nullable=False), sa.Column('item_collection_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('status', sa.Integer(), nullable=False), sa.Column('initiated_at', sa.DateTime(), nullable=False), sa.Column('paid_at', sa.DateTime(), nullable=True), sa.Column('invoiced_at', sa.DateTime(), nullable=True), sa.Column('cancelled_at', sa.DateTime(), nullable=True), sa.Column('access_token', sa.Unicode(length=22), nullable=False), sa.Column('buyer_email', sa.Unicode(length=254), nullable=False), sa.Column('buyer_fullname', sa.Unicode(length=80), nullable=False), sa.Column('buyer_phone', sa.Unicode(length=16), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('invoice_no', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['organization_id'], ['organization.id'], ), sa.ForeignKeyConstraint(['item_collection_id'], ['item_collection.id'], ), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('organization_id', 'invoice_no') ) op.create_table('discount_coupon', sa.Column('code', sa.Unicode(length=20), nullable=False), sa.Column('discount_policy_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('quantity_available', sa.Integer(), nullable=False), sa.Column('quantity_total', sa.Integer(), nullable=False), sa.Column('used_at', sa.DateTime(), nullable=True), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.CheckConstraint('quantity_available <= quantity_total', name='discount_coupon_quantity_check'), sa.ForeignKeyConstraint(['discount_policy_id'], ['discount_policy.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('discount_policy_id', 'code') ) op.create_table('item', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('description_text', sa.UnicodeText(), nullable=False), sa.Column('description_html', sa.UnicodeText(), nullable=False), sa.Column('item_collection_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('category_id', sa.Integer(), nullable=False), sa.Column('quantity_available', sa.Integer(), nullable=False), sa.Column('quantity_total', sa.Integer(), nullable=False), sa.Column('name', sa.Unicode(length=250), nullable=False), sa.Column('title', sa.Unicode(length=250), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['category_id'], ['category.id'], ), sa.ForeignKeyConstraint(['item_collection_id'], ['item_collection.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('item_collection_id', 'name'), sa.CheckConstraint('quantity_available <= quantity_total', name='item_quantity_available_lte_quantity_total_check') ) op.create_table('online_payment', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('customer_order_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('pg_paymentid', sa.Unicode(length=80), nullable=False), sa.Column('pg_payment_status', sa.Integer(), nullable=False), sa.Column('confirmed_at', sa.DateTime(), nullable=True), sa.Column('failed_at', sa.DateTime(), nullable=True), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['customer_order_id'], ['customer_order.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('item_discount_policy', sa.Column('item_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('discount_policy_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['discount_policy_id'], ['discount_policy.id'], ), sa.ForeignKeyConstraint(['item_id'], ['item.id'], ), sa.PrimaryKeyConstraint('item_id', 'discount_policy_id') ) op.create_table('line_item', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('customer_order_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('item_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('discount_policy_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), sa.Column('discount_coupon_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), sa.Column('base_amount', sa.Numeric(), nullable=False), sa.Column('discounted_amount', sa.Numeric(), nullable=False), sa.Column('final_amount', sa.Numeric(), nullable=False), sa.Column('status', sa.Integer(), nullable=False), sa.Column('ordered_at', sa.DateTime(), nullable=True), sa.Column('cancelled_at', sa.DateTime(), nullable=True), sa.Column('line_item_seq', sa.Integer(), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['customer_order_id'], ['customer_order.id'], ), sa.ForeignKeyConstraint(['discount_policy_id'], ['discount_policy.id'], ), sa.ForeignKeyConstraint(['discount_coupon_id'], ['discount_coupon.id'], ), sa.ForeignKeyConstraint(['item_id'], ['item.id'], ), sa.UniqueConstraint('customer_order_id', 'line_item_seq'), sa.PrimaryKeyConstraint('id') ) op.create_table('payment_transaction', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('customer_order_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('online_payment_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), sa.Column('amount', sa.Numeric(), nullable=False), sa.Column('currency', sa.Unicode(length=3), nullable=False), sa.Column('transaction_type', sa.Integer(), nullable=False), sa.Column('transaction_method', sa.Integer(), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['customer_order_id'], ['customer_order.id'], ), sa.ForeignKeyConstraint(['online_payment_id'], ['online_payment.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('price', sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False), sa.Column('item_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.Column('start_at', sa.DateTime(), nullable=False), sa.Column('end_at', sa.DateTime(), nullable=False), sa.Column('amount', sa.Numeric(), nullable=False), sa.Column('currency', sa.Unicode(length=3), nullable=False), sa.Column('name', sa.Unicode(length=250), nullable=False), sa.Column('title', sa.Unicode(length=250), nullable=False), sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), sa.ForeignKeyConstraint(['item_id'], ['item.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('item_id', 'name'), sa.CheckConstraint('start_at < end_at', name='price_start_at_lt_end_at_check') )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'blacklist_tokens', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('token', sa.String(length=500), nullable=False), sa.Column('blacklisted_on', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('token')) op.create_table( 'brands', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'stores', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=True), sa.Column('email', sa.String(length=80), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email')) op.create_table( 'users', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=True), sa.Column('email', sa.String(length=80), nullable=False), sa.Column('password_hash', sa.String(length=100), nullable=False), sa.Column('dp', sa.String(length=120), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email')) op.create_table( 'inventories', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=50), nullable=True), sa.Column('store_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['store_id'], ['stores.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'roles', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.Enum('ADMIN', 'WORKER', name='roletype'), nullable=True), sa.Column('store_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['store_id'], ['stores.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'products', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=50), nullable=True), sa.Column('dp', sa.String(length=120), nullable=True), sa.Column('inventory_id', sa.Integer(), nullable=False), sa.Column('brand_id', sa.Integer(), nullable=False), sa.Column('quantity_available', sa.Integer(), nullable=True), sa.Column('max_quantity', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['brand_id'], ['brands.id'], ), sa.ForeignKeyConstraint( ['inventory_id'], ['inventories.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('role_user_association', sa.Column('role_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['role_id'], ['roles.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], )) op.create_table( 'items', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('serial_number', sa.String(length=50), nullable=False), sa.Column('is_damaged', sa.Boolean(), nullable=True), sa.Column('is_sold', sa.Boolean(), nullable=True), sa.Column('product_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ['product_id'], ['products.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): op.add_column('import_statistics', sa.Column('copy_data_duration', sa.Integer(), nullable=True)) op.add_column('import_statistics', sa.Column('copy_data_start', sa.DateTime(), nullable=True)) op.add_column('import_statistics', sa.Column('copy_data_stop', sa.DateTime(), nullable=True)) op.add_column( 'import_statistics', sa.Column('copy_schema_duration', sa.Integer(), nullable=True)) op.add_column('import_statistics', sa.Column('copy_schema_start', sa.DateTime(), nullable=True)) op.add_column('import_statistics', sa.Column('copy_schema_stop', sa.DateTime(), nullable=True)) op.add_column('import_statistics_last', sa.Column('copy_data_duration', sa.Integer(), nullable=True)) op.add_column('import_statistics_last', sa.Column('copy_data_start', sa.DateTime(), nullable=True)) op.add_column('import_statistics_last', sa.Column('copy_data_stop', sa.DateTime(), nullable=True)) op.add_column( 'import_statistics_last', sa.Column('copy_schema_duration', sa.Integer(), nullable=True)) op.add_column('import_statistics_last', sa.Column('copy_schema_start', sa.DateTime(), nullable=True)) op.add_column('import_statistics_last', sa.Column('copy_schema_stop', sa.DateTime(), nullable=True)) op.add_column( 'export_statistics', sa.Column('update_statistics_duration', sa.Integer(), nullable=True)) op.add_column( 'export_statistics', sa.Column('update_statistics_start', sa.DateTime(), nullable=True)) op.add_column( 'export_statistics', sa.Column('update_statistics_stop', sa.DateTime(), nullable=True)) op.add_column( 'export_statistics_last', sa.Column('update_statistics_duration', sa.Integer(), nullable=True)) op.add_column( 'export_statistics_last', sa.Column('update_statistics_start', sa.DateTime(), nullable=True)) op.add_column( 'export_statistics_last', sa.Column('update_statistics_stop', sa.DateTime(), nullable=True)) op.alter_column('import_tables', 'truncate_hive', existing_type=mysql.TINYINT(display_width=4), comment='<NOT USED>', existing_comment='Truncate Hive table before loading it. ', existing_nullable=False, existing_server_default=sa.text("'1'"))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('student_attendance', sa.Column('timestamp', sa.DateTime(), nullable=True))
"""add payment_account
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('srep', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=120), nullable=True), sa.Column('email', sa.String(length=120), nullable=True), sa.Column('repcode', sa.String(length=10), nullable=True), sa.Column('teamcode', sa.String(length=10), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('repcode')) op.create_index(op.f('ix_srep_email'), 'srep', ['email'], unique=True) op.create_index(op.f('ix_srep_name'), 'srep', ['name'], unique=True) op.create_table( 'leaver', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=True), sa.Column('prosrole', sa.String(length=100), nullable=True), sa.Column('prosfirm', sa.String(length=100), nullable=True), sa.Column('prosnum', sa.Integer(), nullable=True), sa.Column('repcode', sa.String(length=10), nullable=True), sa.Column('teamcode', sa.String(length=10), nullable=True), sa.Column('datetimeadded', sa.DateTime(), nullable=True), sa.Column('inprosshell', sa.String(length=10), nullable=True), sa.Column('result', sa.String(length=50), nullable=True), sa.Column('leaverrole', sa.String(length=250), nullable=True), sa.Column('leaverfirm', sa.String(length=100), nullable=True), sa.Column('leaverlocation', sa.String(length=100), nullable=True), sa.Column('link', sa.String(length=200), nullable=True), sa.Column('trackrole', sa.String(length=250), nullable=True), sa.Column('trackfirm', sa.String(length=100), nullable=True), sa.Column('tracklocation', sa.String(length=100), nullable=True), sa.Column('lasttracked', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['repcode'], ['srep.repcode'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_leaver_datetimeadded'), 'leaver', ['datetimeadded'], unique=False) op.create_index(op.f('ix_leaver_lasttracked'), 'leaver', ['lasttracked'], unique=False) op.create_table( 'suspect', sa.Column('id', sa.Integer(), nullable=False), sa.Column('leaverid', sa.Integer(), nullable=True), sa.Column('name', sa.String(length=100), nullable=True), sa.Column('srole', sa.String(length=250), nullable=True), sa.Column('sfirm', sa.String(length=100), nullable=True), sa.Column('slocation', sa.String(length=75), nullable=True), sa.Column('slink', sa.String(length=100), nullable=True), sa.Column('datetimeadded', sa.DateTime(), nullable=True), sa.Column('datetimeresult', sa.DateTime(), nullable=True), sa.Column('result', sa.String(length=50), nullable=True), sa.ForeignKeyConstraint( ['leaverid'], ['leaver.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('slink')) op.create_index(op.f('ix_suspect_datetimeadded'), 'suspect', ['datetimeadded'], unique=False) op.create_index(op.f('ix_suspect_datetimeresult'), 'suspect', ['datetimeresult'], unique=False)
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table( 'auth_user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('first_name', sa.String(length=255), nullable=True), sa.Column('last_name', sa.String(length=255), nullable=True), sa.Column('username', sa.String(length=120), nullable=True), sa.Column('email', sa.String(length=120), nullable=True), sa.Column('phone', sa.String(length=20), nullable=True), sa.Column('company', sa.String(length=255), nullable=True), sa.Column('country', sa.String(length=120), nullable=True), sa.Column('website', sa.String(length=120), nullable=True), sa.Column('industry', sa.String(length=120), nullable=True), sa.Column('company_size', sa.String(length=120), nullable=True), sa.Column('password', sa.String(length=255), server_default='', nullable=False), sa.Column('time_zone', sa.DateTime(), nullable=True), sa.Column('dst', sa.Boolean(), nullable=True), sa.Column('logo_image_name', sa.Unicode(length=64), nullable=True), sa.Column('logo_image_path', sa.Unicode(length=128), nullable=True), sa.Column('parent', sa.Integer(), nullable=True), sa.Column('is_admin', sa.Boolean(), nullable=True), sa.Column('is_active', sa.Boolean(), server_default='1', nullable=True), sa.Column('date_created', sa.DateTime(), nullable=True), sa.Column('date_modified', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['parent'], ['auth_user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username')) op.create_table('role', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=50), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name')) op.create_table( 'credit_card', sa.Column('id', sa.Integer(), nullable=False), sa.Column('card_holders_name', sa.String(length=255), nullable=True), sa.Column('card_number', sa.String(length=16), nullable=True), sa.Column('card_type', sa.String(length=25), nullable=True), sa.Column('expiration_month', sa.String(length=2), nullable=True), sa.Column('expiration_year', sa.String(length=4), nullable=True), sa.Column('billing_company', sa.String(length=255), nullable=True), sa.Column('billing_address', sa.String(length=255), nullable=True), sa.Column('city', sa.String(length=120), nullable=True), sa.Column('state', sa.String(length=120), nullable=True), sa.Column('zip_code', sa.String(length=20), nullable=True), sa.Column('country', sa.String(length=120), nullable=True), sa.Column('is_active', sa.Boolean(), server_default='1', nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['auth_user.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id')) op.create_table( 'user_roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('role_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['role_id'], ['role.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['auth_user.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'))
def upgrade(): op.add_column("metrics", sa.Column("changed_by_fk", sa.Integer(), nullable=True)) op.add_column("metrics", sa.Column("changed_on", sa.DateTime(), nullable=True)) op.add_column("metrics", sa.Column("created_by_fk", sa.Integer(), nullable=True)) op.add_column("metrics", sa.Column("created_on", sa.DateTime(), nullable=True)) try: op.alter_column( "columns", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "columns", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "css_templates", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "css_templates", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "dashboards", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "dashboards", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "datasources", "changed_by_fk", existing_type=sa.INTEGER(), nullable=True ) op.alter_column( "datasources", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "datasources", "created_by_fk", existing_type=sa.INTEGER(), nullable=True ) op.alter_column( "datasources", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column("dbs", "changed_on", existing_type=sa.DATETIME(), nullable=True) op.alter_column("dbs", "created_on", existing_type=sa.DATETIME(), nullable=True) op.alter_column( "slices", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "slices", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "sql_metrics", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "sql_metrics", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "table_columns", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "table_columns", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "tables", "changed_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column( "tables", "created_on", existing_type=sa.DATETIME(), nullable=True ) op.alter_column("url", "changed_on", existing_type=sa.DATETIME(), nullable=True) op.alter_column("url", "created_on", existing_type=sa.DATETIME(), nullable=True) op.create_foreign_key(None, "metrics", "ab_user", ["changed_by_fk"], ["id"]) op.create_foreign_key(None, "metrics", "ab_user", ["created_by_fk"], ["id"]) except: pass
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=255), nullable=True), sa.Column('email', sa.String(length=255), nullable=True), sa.Column('bio', sa.String(length=255), nullable=True), sa.Column('profile_pic_path', sa.String(), nullable=True), sa.Column('pass_secure', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) op.create_table( 'pitches', sa.Column('id', sa.Integer(), nullable=False), sa.Column('description', sa.String(), nullable=True), sa.Column('title', sa.String(), nullable=True), sa.Column('category', sa.String(length=255), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('time', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_index(op.f('ix_pitches_description'), 'pitches', ['description'], unique=False) op.create_table('profile_photos', sa.Column('id', sa.Integer(), nullable=False), sa.Column('pic_path', sa.String(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('users_id', sa.Integer(), nullable=True), sa.Column('pitch_id', sa.Integer(), nullable=False), sa.Column('time', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['pitch_id'], ['pitches.id'], ), sa.ForeignKeyConstraint( ['users_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('downvotes', sa.Column('id', sa.Integer(), nullable=False), sa.Column('downvote', sa.Integer(), nullable=True), sa.Column('pitch_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['pitch_id'], ['pitches.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table('upvotes', sa.Column('id', sa.Integer(), nullable=False), sa.Column('upvote', sa.Integer(), nullable=True), sa.Column('pitch_id', sa.Integer(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['pitch_id'], ['pitches.id'], ), sa.ForeignKeyConstraint( ['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'miembros', sa.Column('id', sa.Integer(), nullable=False), sa.Column('nombre', sa.String(length=150), nullable=False), sa.Column('apellido', sa.String(length=150), nullable=False), sa.Column('email', sa.String(length=150), nullable=False), sa.Column('password', sa.String(length=150), nullable=False), sa.Column('puntos', sa.Integer(), nullable=True), sa.Column('comentario', sa.String(length=300), nullable=True), sa.Column('fecha_de_registro', sa.DateTime(timezone=True), nullable=True), sa.Column('fecha_de_nacimiento', sa.Date(), nullable=True), sa.Column('estado', sa.Enum('Activo', 'Inactivo'), nullable=False), sa.Column('permiso', sa.String(length=300), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'productos', sa.Column('id', sa.Integer(), nullable=False), sa.Column('nombre', sa.String(length=150), nullable=False), sa.Column('urlImage', sa.String(length=150), nullable=False), sa.Column('puntos', sa.Integer(), nullable=False), sa.Column('descripcion', sa.String(length=150), nullable=False), sa.PrimaryKeyConstraint('id')) op.create_table( 'transacciones', sa.Column('id', sa.Integer(), nullable=False), sa.Column('descripcion', sa.String(length=300), nullable=True), sa.Column('tipo', sa.Enum('Acumulo', 'Canje'), nullable=False), sa.Column('monto', sa.Integer(), nullable=True), sa.Column('puntos', sa.Integer(), nullable=True), sa.Column('fecha_creacion', sa.DateTime(timezone=True), nullable=True), sa.Column('fecha_ultima_actualizacion', sa.DateTime(timezone=True), nullable=True), sa.Column('id_miembro', sa.Integer(), nullable=True), sa.Column('id_producto', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['id_miembro'], ['miembros.id'], ), sa.ForeignKeyConstraint( ['id_producto'], ['productos.id'], ), sa.PrimaryKeyConstraint('id')) op.create_table( 'vouchers', sa.Column('id', sa.Integer(), nullable=False), sa.Column('estado', sa.Enum('Disponible', 'Usado'), nullable=False), sa.Column('fecha_de_creacion', sa.DateTime(timezone=True), nullable=True), sa.Column('fecha_de_vencimiento', sa.DateTime(timezone=True), nullable=True), sa.Column('id_miembro', sa.Integer(), nullable=True), sa.Column('id_producto', sa.Integer(), nullable=True), sa.ForeignKeyConstraint( ['id_miembro'], ['miembros.id'], ), sa.ForeignKeyConstraint( ['id_producto'], ['productos.id'], ), sa.PrimaryKeyConstraint('id'))
def upgrade(): op.create_table('user', sa.Column('id', sa.Integer(), nullable=False), sa.Column('email', sa.Unicode(), nullable=False), sa.Column('display_name', sa.Unicode(), nullable=True), sa.Column('password_hash', sa.Unicode(), nullable=False), sa.Column('is_admin', sa.Boolean(), nullable=False), sa.Column('is_editor', sa.Boolean(), nullable=False), sa.Column('active', sa.Boolean(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_table('card', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.Unicode(), nullable=False), sa.Column('category', sa.Enum('Person', 'Company', 'Organization', 'Article'), nullable=False), sa.Column('text', sa.Unicode(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('spider_tag', sa.Column('id', sa.Integer(), nullable=False), sa.Column('spider', sa.Unicode(), nullable=True), sa.Column('card_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['card_id'], ['card.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('reference', sa.Column('id', sa.Integer(), nullable=False), sa.Column('score', sa.Integer(), nullable=False), sa.Column('citation', sa.Unicode(), nullable=False), sa.Column('url', sa.Unicode(), nullable=False), sa.Column('source', sa.Unicode(), nullable=True), sa.Column('source_url', sa.Unicode(), nullable=True), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('card_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['user.id'], ), sa.ForeignKeyConstraint(['card_id'], ['card.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('alias', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.Unicode(), nullable=True), sa.Column('card_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['card_id'], ['card.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('link', sa.Column('id', sa.Integer(), nullable=False), sa.Column('offset', sa.Integer(), nullable=False), sa.Column('status', sa.Enum('pending', 'approved', 'rejected'), nullable=False), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('parent_id', sa.Integer(), nullable=True), sa.Column('child_id', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['author_id'], ['user.id'], ), sa.ForeignKeyConstraint(['child_id'], ['card.id'], ), sa.ForeignKeyConstraint(['parent_id'], ['card.id'], ), sa.PrimaryKeyConstraint('id') )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('gateway', sa.Column('last_seen', sa.DateTime(), nullable=True))
class User(Base): __tablename__ = 'user' @declared_attr def __table_args__(cls): # noqa: N805 return ( # (email, authority) must be unique sa.UniqueConstraint('email', 'authority'), # (normalised username, authority) must be unique. This index is # also critical for making user lookups fast. sa.Index('ix__user__userid', _normalise_username(cls.username), cls.authority, unique=True), # Optimize lookup of shadowbanned users. sa.Index('ix__user__nipsa', cls.nipsa, postgresql_where=cls.nipsa.is_(True)), ) id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) #: Username as chosen by the user on registration _username = sa.Column('username', sa.UnicodeText(), nullable=False) #: The "authority" for this user. This represents the "namespace" in which #: this user lives. By default, all users are created in the namespace #: corresponding to `request.domain`, but this can be overridden with the #: `h.authority` setting. authority = sa.Column('authority', sa.UnicodeText(), nullable=False) #: The display name which will be used when rendering an annotation. display_name = sa.Column(sa.UnicodeText()) #: A short user description/bio description = sa.Column(sa.UnicodeText()) #: A free-form column to allow the user to say where they are location = sa.Column(sa.UnicodeText()) #: The user's URI/link on the web uri = sa.Column(sa.UnicodeText()) #: The user's ORCID ID #orcid = sa.Column(sa.UnicodeText()) #: Is this user an admin member? admin = sa.Column(sa.Boolean, default=False, nullable=False, server_default=sa.sql.expression.false()) #: Is this user a staff member? staff = sa.Column(sa.Boolean, nullable=False, default=False, server_default=sa.sql.expression.false()) #: Is this user flagged as "Not (Suitable) In Public Site Areas" (AKA #: NIPSA). This flag is used to shadow-ban a user so their annotations #: don't appear to anyone but themselves. nipsa = sa.Column(sa.Boolean, nullable=False, default=False, server_default=sa.sql.expression.false()) sidebar_tutorial_dismissed = sa.Column( sa.Boolean, default=False, server_default=(sa.sql.expression.false())) #: A timestamp representing the last time the user accepted the privacy policy. #: A NULL value in this column indicates the user has never accepted a privacy policy. privacy_accepted = sa.Column(sa.DateTime, nullable=True) identities = sa.orm.relationship("UserIdentity", backref="user", cascade="all, delete-orphan") @hybrid_property def username(self): return self._username @username.setter def username(self, value): self._username = value @username.comparator def username(cls): # noqa: N805 return UsernameComparator(cls._username) @hybrid_property def userid(self): return 'acct:{username}@{authority}'.format(username=self.username, authority=self.authority) @userid.comparator def userid(cls): # noqa: N805 return UserIDComparator(cls.username, cls.authority) email = sa.Column(sa.UnicodeText()) last_login_date = sa.Column(sa.TIMESTAMP(timezone=False), default=datetime.datetime.utcnow, server_default=sa.func.now(), nullable=False) registered_date = sa.Column(sa.TIMESTAMP(timezone=False), default=datetime.datetime.utcnow, server_default=sa.func.now(), nullable=False) # Activation foreign key activation_id = sa.Column(sa.Integer, sa.ForeignKey('activation.id')) activation = sa.orm.relationship('Activation', backref='user') @property def is_activated(self): if self.activation_id is None: return True return False def activate(self): """Activate the user by deleting any activation they have.""" session = sa.orm.object_session(self) session.delete(self.activation) #: Hashed password password = sa.Column(sa.UnicodeText(), nullable=True) #: Last password update password_updated = sa.Column(sa.DateTime(), nullable=True) #: Password salt #: #: N.B. This field is DEPRECATED. The password context we use already #: manages the generation of a random salt when hashing a password and we #: don't need a separate salt column. This remains for "legacy" passwords #: which were, sadly, double-salted. As users log in, we are slowly #: upgrading their passwords and setting this column to None. salt = sa.Column(sa.UnicodeText(), nullable=True) @sa.orm.validates('email') def validate_email(self, key, email): if email is None: return email if len(email) > EMAIL_MAX_LENGTH: raise ValueError('email must be less than {max} characters ' 'long'.format(max=EMAIL_MAX_LENGTH)) return email @sa.orm.validates('_username') def validate_username(self, key, username): if not USERNAME_MIN_LENGTH <= len(username) <= USERNAME_MAX_LENGTH: raise ValueError('username must be between {min} and {max} ' 'characters long'.format(min=USERNAME_MIN_LENGTH, max=USERNAME_MAX_LENGTH)) if not re.match(USERNAME_PATTERN, username): raise ValueError('username must have only letters, numbers, ' 'periods, and underscores.') return username @classmethod def get_by_email(cls, session, email, authority): """Fetch a user by email address.""" if email is None: return None return session.query(cls).filter( sa.func.lower(cls.email) == email.lower(), cls.authority == authority, ).first() @classmethod def get_by_activation(cls, session, activation): """Fetch a user by activation instance.""" user = session.query(cls).filter( cls.activation_id == activation.id).first() return user @classmethod def get_by_username(cls, session, username, authority): """Fetch a user by username.""" return session.query(cls).filter( cls.username == username, cls.authority == authority, ).first() def __repr__(self): return '<User: %s>' % self.username
def upgrade(): op.add_column('account', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('account', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('bot', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('bot', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('broadcast', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('broadcast', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('colleted_data', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('colleted_data', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('content_module', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('content_module', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('conversation', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('conversation', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('entry', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('entry', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('event', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('event', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('feed', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('feed', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('linkage', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('linkage', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('node', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('node', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('oauth_info', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('oauth_info', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('parser_module', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('parser_module', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('platform', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('platform', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('public_feed', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('public_feed', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('tag', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('tag', sa.Column('updated_at', sa.DateTime(), nullable=False)) op.add_column('user', sa.Column('created_at', sa.DateTime(), nullable=False)) op.add_column('user', sa.Column('updated_at', sa.DateTime(), nullable=False)) # Populate with default values for obj_name in dir(database): obj = getattr(database, obj_name) if (inspect.isclass(obj) and issubclass(obj, database.ModelMixin) and obj != database.ModelMixin): now = datetime.datetime.utcnow() op.execute( obj.__table__.update().values({ obj.created_at: now, obj.updated_at: now }) )
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'books', sa.Column('id', sa.Integer(), nullable=False), sa.Column('book_name', sa.String(length=100), nullable=False), sa.Column('author_name', sa.String(length=30), nullable=False), sa.Column('book_dept', sa.String(length=20), nullable=False), sa.Column('book_cost', sa.String(length=20), nullable=False), sa.Column('book_des', sa.String(length=10000), nullable=False), sa.Column('year_published', sa.String(length=20), nullable=False), sa.Column('book_pub', sa.String(length=50), nullable=False), sa.Column('isbn_number', sa.String(length=20), nullable=False), sa.Column('image_file', sa.String(length=20), nullable=False), sa.Column('no_of_pages', sa.Integer(), nullable=False), sa.Column('no_of_copies', sa.Integer(), nullable=False), sa.Column('no_ofCopies', sa.Integer(), nullable=False), sa.Column('floor_no', sa.Integer(), nullable=False), sa.Column('rack_no', sa.Integer(), nullable=False), sa.Column('shelf_no', sa.Integer(), nullable=False), sa.Column('date_posted', sa.DateTime(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('isbn_number')) op.create_table( 'borrow_book', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=20), nullable=False), sa.Column('book_name', sa.String(length=100), nullable=False), sa.Column('author_name', sa.String(length=20), nullable=False), sa.Column('book_dept', sa.String(length=20), nullable=False), sa.Column('isbn_number', sa.String(length=20), nullable=False), sa.Column('borrow_time', sa.DateTime(), nullable=False), sa.Column('renew_time', sa.DateTime(), nullable=False), sa.Column('image_file', sa.String(length=20), nullable=False), sa.Column('fine', sa.Integer(), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('isbn_number')) op.create_table( 'cart', sa.Column('id', sa.Integer(), nullable=False), sa.Column('book_name', sa.String(length=100), nullable=False), sa.Column('author_name', sa.String(length=20), nullable=False), sa.Column('book_dept', sa.String(length=20), nullable=False), sa.Column('isbn_number', sa.String(length=20), nullable=False), sa.Column('image_file', sa.String(length=20), nullable=False), sa.Column('username', sa.String(length=20), nullable=False), sa.Column('typeofmembership', sa.String(length=20), nullable=False), sa.Column('no_of_copies', sa.Integer(), nullable=False), sa.Column('first_name', sa.String(length=20), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('author_name'), sa.UniqueConstraint('isbn_number')) op.create_table( 'country', sa.Column('id', sa.Integer(), nullable=False), sa.Column('alpha_2', sa.String(length=5), nullable=False), sa.Column('alpha_3', sa.String(length=5), nullable=False), sa.Column('name', sa.String(length=50), nullable=False), sa.Column('numeric', sa.String(length=10), nullable=False), sa.Column('official_name', sa.String(length=100), nullable=True), sa.PrimaryKeyConstraint('id')) op.create_table( 'requestion', sa.Column('id', sa.Integer(), nullable=False), sa.Column('username', sa.String(length=20), nullable=False), sa.Column('book_name', sa.String(length=20), nullable=False), sa.Column('author_name', sa.String(length=20), nullable=False), sa.Column('book_dept', sa.String(length=20), nullable=False), sa.Column('book_implementation', sa.String(length=500), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('author_name'), sa.UniqueConstraint('username')) op.create_table( 'users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('first_name', sa.String(length=20), nullable=False), sa.Column('last_name', sa.String(length=20), nullable=False), sa.Column('date_of_birth', sa.String(length=10), nullable=False), sa.Column('door_no', sa.String(length=3), nullable=False), sa.Column('street_name', sa.String(length=70), nullable=False), sa.Column('area_name', sa.String(length=20), nullable=False), sa.Column('country', sa.String(length=20), nullable=False), sa.Column('state', sa.String(length=20), nullable=False), sa.Column('postal_code', sa.String(length=7), nullable=False), sa.Column('mobile_number', sa.String(length=14), nullable=False), sa.Column('username', sa.String(length=20), nullable=False), sa.Column('typeofmembership', sa.String(length=20), nullable=False), sa.Column('email', sa.String(length=120), nullable=False), sa.Column('image_file', sa.String(length=20), nullable=False), sa.Column('password', sa.String(length=60), nullable=False), sa.Column('security', sa.String(length=20), nullable=False), sa.Column('Account_type', sa.String(length=20), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('username'))
def upgrade(): op.add_column('repos', sa.Column('status_updated_at', sa.DateTime(), nullable=True))
def upgrade(): from inbox.sqlalchemy_ext.util import Base36UID print "Rename WebhookParameters -> Webhook" op.rename_table('webhookparameters', 'webhook') op.drop_index('ix_webhookparameters_public_id', table_name='webhook') op.create_index( 'ix_webhook_namespace_id', 'webhook', ['namespace_id'], unique=False) op.create_index( 'ix_webhook_public_id', 'webhook', ['public_id'], unique=False) op.create_foreign_key('webhooks_ibfk_1', 'webhook', 'namespace', ['namespace_id'], ['id'], ondelete='CASCADE') print 'Creating Lens' op.create_table('lens', sa.Column('id', sa.Integer(), nullable=False), sa.Column( 'public_id', Base36UID(length=16), nullable=False), sa.Column('namespace_id', sa.Integer(), nullable=False), sa.Column('subject', sa.String(length=255), nullable=True), sa.Column( 'thread_public_id', Base36UID(length=16), nullable=True), sa.Column('started_before', sa.DateTime(), nullable=True), sa.Column('started_after', sa.DateTime(), nullable=True), sa.Column( 'last_message_before', sa.DateTime(), nullable=True), sa.Column( 'last_message_after', sa.DateTime(), nullable=True), sa.Column( 'any_email', sa.String(length=255), nullable=True), sa.Column('to_addr', sa.String(length=255), nullable=True), sa.Column( 'from_addr', sa.String(length=255), nullable=True), sa.Column('cc_addr', sa.String(length=255), nullable=True), sa.Column( 'bcc_addr', sa.String(length=255), nullable=True), sa.Column( 'filename', sa.String(length=255), nullable=True), sa.Column('tag', sa.String(length=255), nullable=True), sa.ForeignKeyConstraint( ['namespace_id'], ['namespace.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index( 'ix_lens_namespace_id', 'lens', ['namespace_id'], unique=False) op.create_index('ix_lens_public_id', 'lens', ['public_id'], unique=False) print 'Removing old webhooks' op.add_column( u'webhook', sa.Column('lens_id', sa.Integer(), nullable=False)) op.drop_column(u'webhook', u'last_message_after') op.drop_column(u'webhook', u'last_message_before') op.drop_column(u'webhook', u'thread') op.drop_column(u'webhook', u'from_addr') op.drop_column(u'webhook', u'started_after') op.drop_column(u'webhook', u'to_addr') op.drop_column(u'webhook', u'filename') op.drop_column(u'webhook', u'bcc_addr') op.drop_column(u'webhook', u'cc_addr') op.drop_column(u'webhook', u'started_before') op.drop_column(u'webhook', u'email') op.drop_column(u'webhook', u'subject') op.create_index('ix_webhook_lens_id', 'webhook', ['lens_id'], unique=False)