Upgrade database.
179830
def upgrade():
    """"""
    op.execute('COMMIT')  # See https://bitbucket.org/zzzeek/alembic/issue/123
    ctx = op.get_context()
    metadata = ctx.opts['target_metadata']
    metadata.naming_convention = NAMING_CONVENTION
    metadata.bind = ctx.connection.engine
    insp = Inspector.from_engine(ctx.connection.engine)

    for table_name in insp.get_table_names():
        if table_name not in metadata.tables:
            continue

        table = metadata.tables[table_name]

        ixs = {}
        uqs = {}
        fks = {}

        for ix in insp.get_indexes(table_name):
            ixs[tuple(ix['column_names'])] = ix
        for uq in insp.get_unique_constraints(table_name):
            uqs[tuple(uq['column_names'])] = uq
        for fk in insp.get_foreign_keys(table_name):
            fks[(tuple(fk['constrained_columns']), fk['referred_table'])] = fk

        with op.batch_alter_table(
                table_name, naming_convention=NAMING_CONVENTION) as batch_op:
            for c in list(table.constraints) + list(table.indexes):
                key = None
                if isinstance(c, sa.schema.ForeignKeyConstraint):
                    key = (tuple(c.column_keys), c.referred_table.name)
                    fk = fks.get(key)
                    if fk and c.name != fk['name']:
                        batch_op.drop_constraint(
                            fk['name'], type_='foreignkey')
                        batch_op.create_foreign_key(
                            op.f(c.name), fk['referred_table'],
                            fk['constrained_columns'],
                            fk['referred_columns'],
                            **fk['options']
                        )
                elif isinstance(c, sa.schema.UniqueConstraint):
                    key = tuple(c.columns.keys())
                    uq = uqs.get(key)
                    if uq and c.name != uq['name']:
                        batch_op.drop_constraint(uq['name'], type_='unique')
                        batch_op.create_unique_constraint(
                            op.f(c.name), uq['column_names'])
                elif isinstance(c, sa.schema.CheckConstraint):
                    util.warn('Update {0.table.name} CHECK {0.name} '
                              'manually'.format(c))
                elif isinstance(c, sa.schema.Index):
                    key = tuple(c.columns.keys())
                    ix = ixs.get(key)
                    if ix and c.name != ix['name']:
                        batch_op.drop_index(ix['name'])
                        batch_op.create_index(
                            op.f(c.name), ix['column_names'],
                            unique=ix['unique'],
                        )
                elif isinstance(c, sa.schema.PrimaryKeyConstraint) or \
                        c.name == '_unnamed_':
                    # NOTE we don't care about primary keys since they have
                    # specific syntax.
                    pass
                else:
                    raise RuntimeError('Missing {0!r}'.format(c))
893800
public function upgradeDatabase()
    {
        $job = Job::getByHandle('fill_thumbnails_table');
        if ($job === null) {
            Job::installByHandle('fill_thumbnails_table');
            $job = Job::getByHandle('fill_thumbnails_table');
            if ($job !== null) {
                $set = Set::getByName('Default');
                if ($set !== null) {
                    $set->addJob($job);
                }
            }
        }
        $sp = Page::getByPath('/dashboard/system/files/image_uploading');
        if (is_object($sp) && !$sp->isError()) {
            $sp->update([
                'cName' => 'Image Options',
            ]);
            if ($this->isAttributeHandleValid(PageCategory::class, 'meta_keywords')) {
                $sp->setAttribute('meta_keywords', 'uploading, upload, images, image, resizing, manager, exif, rotation, rotate, quality, compression, png, jpg, jpeg');
            }
        }
        $config = $this->app->make('config');
        $restrict_uploaded_image_sizes = $config->get('concrete.file_manager.restrict_uploaded_image_sizes');
        if ($restrict_uploaded_image_sizes !== null) {
            if (!$restrict_uploaded_image_sizes) {
                $config->save('concrete.file_manager.restrict_max_width', null);
                $config->save('concrete.file_manager.restrict_max_height', null);
            }
            $config->set('concrete.file_manager.restrict_uploaded_image_sizes', null);
            $config->save('concrete.file_manager.restrict_uploaded_image_sizes', null);
        }
    }
741819
public function upgrade(): void
    {
        DB::schema()->create('gedcom', static function (Blueprint $table): void {
            $table->integer('gedcom_id', true);
            $table->string('gedcom_name', 255);
            $table->integer('sort_order')->default(0);

            $table->unique('gedcom_name');
            $table->index('sort_order');
        });

        DB::schema()->create('site_setting', static function (Blueprint $table): void {
            $table->string('setting_name', 32);
            $table->string('setting_value', 2000);

            $table->primary('setting_name');
        });

        DB::schema()->create('gedcom_setting', static function (Blueprint $table): void {
            $table->integer('gedcom_id');
            $table->string('setting_name', 32);
            $table->string('setting_value', 255);

            $table->primary(['gedcom_id', 'setting_name']);

            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('user', static function (Blueprint $table): void {
            $table->integer('user_id', true);
            $table->string('user_name', 32);
            $table->string('real_name', 64);
            $table->string('email', 64);
            $table->string('password', 128);

            $table->unique('user_name');
            $table->unique('email');
        });

        DB::schema()->create('user_setting', static function (Blueprint $table): void {
            $table->integer('user_id');
            $table->string('setting_name', 32);
            $table->string('setting_value', 255);

            $table->primary(['user_id', 'setting_name']);

            $table->foreign('user_id')->references('user_id')->on('user');
        });

        DB::schema()->create('user_gedcom_setting', static function (Blueprint $table): void {
            $table->integer('user_id');
            $table->integer('gedcom_id');
            $table->string('setting_name', 32);
            $table->string('setting_value', 255);

            $table->primary(['user_id', 'gedcom_id', 'setting_name']);
            $table->index('gedcom_id');

            $table->foreign('user_id')->references('user_id')->on('user');
            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('log', static function (Blueprint $table): void {
            $table->integer('log_id', true);
            $table->timestamp('log_time')->useCurrent();
            $table->enum('log_type', ['auth', 'config', 'debug', 'edit', 'error', 'media', 'search']);
            $table->longText('log_message');
            $table->ipAddress('ip_address');
            $table->integer('user_id')->nullable();
            $table->integer('gedcom_id')->nullable();

            $table->index('log_time');
            $table->index('log_type');
            $table->index('ip_address');
            $table->index('user_id');
            $table->index('gedcom_id');

            $table->foreign('user_id')->references('user_id')->on('user');
            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('change', static function (Blueprint $table): void {
            $table->integer('change_id', true);
            $table->timestamp('change_time')->useCurrent();
            $table->enum('status', ['accepted', 'pending', 'rejected'])->default('pending');
            $table->integer('gedcom_id');
            $table->string('xref', 20);
            $table->longText('old_gedcom');
            $table->longText('new_gedcom');
            $table->integer('user_id');

            $table->index(['gedcom_id', 'status', 'xref']);
            $table->index('user_id');

            $table->foreign('user_id')->references('user_id')->on('user');
            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('message', static function (Blueprint $table): void {
            $table->integer('message_id', true);
            $table->string('sender', 64);
            $table->ipAddress('ip_address');
            $table->integer('user_id');
            $table->string('subject', 255);
            $table->longText('body');
            $table->timestamp('created')->useCurrent();

            $table->index('user_id');

            $table->foreign('user_id')->references('user_id')->on('user');
        });

        DB::schema()->create('default_resn', static function (Blueprint $table): void {
            $table->integer('default_resn_id', true);
            $table->integer('gedcom_id');
            $table->string('xref', 20)->nullable();
            $table->string('tag_type', 15)->nullable();
            $table->enum('resn', ['none', 'privacy', 'confidential', 'hidden']);
            $table->string('comment', 255)->nullable();
            $table->timestamp('updated')->useCurrent();

            $table->unique(['gedcom_id', 'xref', 'tag_type']);

            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('individuals', static function (Blueprint $table): void {
            $table->string('i_id', 20);
            $table->integer('i_file');
            $table->string('i_rin', 20);
            $table->enum('i_sex', ['U', 'M', 'F']);
            $table->longText('i_gedcom');

            $table->primary(['i_id', 'i_file']);
            $table->unique(['i_file', 'i_id']);
        });

        DB::schema()->create('families', static function (Blueprint $table): void {
            $table->string('f_id', 20);
            $table->integer('f_file');
            $table->string('f_husb', 20)->nullable();
            $table->string('f_wife', 20)->nullable();
            $table->longText('f_gedcom');
            $table->integer('f_numchil');

            $table->primary(['f_id', 'f_file']);
            $table->unique(['f_file', 'f_id']);
            $table->index('f_husb');
            $table->index('f_wife');
        });

        DB::schema()->create('places', static function (Blueprint $table): void {
            $table->integer('p_id', true);
            $table->string('p_place', 150);
            $table->integer('p_parent_id')->nullable();
            $table->integer('p_file');
            $table->longText('p_std_soundex')->nullable();
            $table->longText('p_dm_soundex')->nullable();

            $table->index(['p_file', 'p_place']);
            $table->unique(['p_parent_id', 'p_file', 'p_place']);
        });

        DB::schema()->create('placelinks', static function (Blueprint $table): void {
            $table->integer('pl_p_id');
            $table->string('pl_gid', 20);
            $table->integer('pl_file');

            $table->primary(['pl_p_id', 'pl_gid', 'pl_file']);
            $table->index('pl_p_id');
            $table->index('pl_gid');
            $table->index('pl_file');
        });

        DB::schema()->create('dates', static function (Blueprint $table): void {
            $table->tinyInteger('d_day');
            $table->char('d_month', 5)->nullable();
            $table->tinyInteger('d_mon');
            $table->smallInteger('d_year');
            $table->mediumInteger('d_julianday1');
            $table->mediumInteger('d_julianday2');
            $table->string('d_fact', 15);
            $table->string('d_gid', 20);
            $table->integer('d_file');
            $table->enum('d_type', ['@#DGREGORIAN@', '@#DJULIAN@', '@#DHEBREW@', '@#DFRENCH R@', '@#DHIJRI@', '@#DROMAN@', '@#DJALALI@']);

            $table->index('d_day');
            $table->index('d_month');
            $table->index('d_mon');
            $table->index('d_year');
            $table->index('d_julianday1');
            $table->index('d_julianday2');
            $table->index('d_gid');
            $table->index('d_file');
            $table->index('d_type');
            $table->index(['d_fact', 'd_gid']);
        });

        DB::schema()->create('media', static function (Blueprint $table): void {
            $table->string('m_id', 20);
            $table->string('m_ext', 6)->nullable();
            $table->string('m_type', 20)->nullable();
            $table->string('m_titl', 248)->nullable();
            $table->string('m_filename', 248)->nullable();
            $table->integer('m_file');
            $table->longText('m_gedcom')->nullable();

            $table->primary(['m_file', 'm_id']);
            $table->unique(['m_id', 'm_file']);
            $table->index(['m_ext', 'm_type']);
        });

        DB::schema()->create('next_id', static function (Blueprint $table): void {
            $table->integer('gedcom_id');
            $table->string('record_type', 15);
            $table->decimal('next_id', 20, 0);

            $table->primary(['gedcom_id', 'record_type']);

            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('other', static function (Blueprint $table): void {
            $table->string('o_id', 20);
            $table->integer('o_file');
            $table->string('o_type', 15);
            $table->longText('o_gedcom');

            $table->primary(['o_id', 'o_file']);
            $table->unique(['o_file', 'o_id']);
        });

        DB::schema()->create('sources', static function (Blueprint $table): void {
            $table->string('s_id', 20);
            $table->integer('s_file');
            $table->string('s_name', 255);
            $table->longText('s_gedcom');

            $table->primary(['s_id', 's_file']);
            $table->unique(['s_file', 's_id']);
            $table->index('s_name');
        });

        DB::schema()->create('link', static function (Blueprint $table): void {
            $table->integer('l_file');
            $table->string('l_from', 20);
            $table->string('l_type', 15);
            $table->string('l_to', 20);

            $table->primary(['l_from', 'l_file', 'l_type', 'l_to']);
            $table->unique(['l_to', 'l_file', 'l_type', 'l_from']);
        });

        DB::schema()->create('name', static function (Blueprint $table): void {
            $table->integer('n_file');
            $table->string('n_id', 20);
            $table->integer('n_num');
            $table->string('n_type', 15);
            $table->string('n_sort', 255);
            $table->string('n_full', 255);
            $table->string('n_surname', 255)->nullable();
            $table->string('n_surn', 255)->nullable();
            $table->string('n_givn', 255)->nullable();
            $table->string('n_soundex_givn_std', 255)->nullable();
            $table->string('n_soundex_surn_std', 255)->nullable();
            $table->string('n_soundex_givn_dm', 255)->nullable();
            $table->string('n_soundex_surn_dm', 255)->nullable();

            $table->primary(['n_id', 'n_file', 'n_num']);
            $table->index(['n_full', 'n_id', 'n_file']);
            $table->index(['n_surn', 'n_file', 'n_type', 'n_id']);
            $table->index(['n_givn', 'n_file', 'n_type', 'n_id']);
        });

        DB::schema()->create('module', static function (Blueprint $table): void {
            $table->string('module_name', 32);
            $table->enum('status', ['enabled', 'disabled'])->default('enabled');
            $table->integer('tab_order')->nullable();
            $table->integer('menu_order')->nullable();
            $table->integer('sidebar_order')->nullable();

            $table->primary('module_name');
        });

        DB::schema()->create('module_setting', static function (Blueprint $table): void {
            $table->string('module_name', 32);
            $table->string('setting_name', 32);
            $table->longText('setting_value');

            $table->primary(['module_name', 'setting_name']);

            $table->foreign('module_name')->references('module_name')->on('module');
        });

        DB::schema()->create('module_privacy', static function (Blueprint $table): void {
            $table->string('module_name', 32);
            $table->integer('gedcom_id');
            $table->enum('component', ['block', 'chart', 'menu', 'report', 'sidebar', 'tab', 'theme']);
            $table->tinyInteger('access_level');

            $table->primary(['module_name', 'gedcom_id', 'component']);
            $table->unique(['gedcom_id', 'module_name', 'component']);

            $table->foreign('module_name')->references('module_name')->on('module');
            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('block', static function (Blueprint $table): void {
            $table->integer('block_id', true);
            $table->integer('gedcom_id')->nullable();
            $table->integer('user_id')->nullable();
            $table->string('xref', 20)->nullable();
            $table->enum('location', ['main', 'side'])->nullable();
            $table->integer('block_order');
            $table->string('module_name', 32);

            $table->index('module_name');
            $table->index('gedcom_id');
            $table->index('user_id');

            $table->foreign('module_name')->references('module_name')->on('module');
            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
            $table->foreign('user_id')->references('user_id')->on('user');
        });

        DB::schema()->create('block_setting', static function (Blueprint $table): void {
            $table->integer('block_id');
            $table->string('setting_name', 32);
            $table->longText('setting_value');

            $table->primary(['block_id', 'setting_name']);

            $table->foreign('block_id')->references('block_id')->on('block');
        });

        DB::schema()->create('hit_counter', static function (Blueprint $table): void {
            $table->integer('gedcom_id');
            $table->string('page_name', 32);
            $table->string('page_parameter', 32);
            $table->integer('page_count');

            $table->primary(['gedcom_id', 'page_name', 'page_parameter']);

            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        DB::schema()->create('session', static function (Blueprint $table): void {
            $table->string('session_id', 32);
            $table->timestamp('session_time')->useCurrent();
            $table->integer('user_id');
            $table->ipAddress('ip_address');
            $table->binary('session_data');

            $table->primary('session_id');
            $table->index('session_time');
            $table->index(['user_id', 'ip_address']);
        });

        // See https://github.com/laravel/framework/issues/3544
        if (DB::connection()->getDriverName() === 'mysql') {
            $table = DB::connection()->getSchemaGrammar()->wrapTable('session');
            $sql   = 'ALTER TABLE ' . $table . ' MODIFY session_data LONGBLOB';
            DB::connection()->statement($sql);
        }

        DB::schema()->create('gedcom_chunk', static function (Blueprint $table): void {
            $table->integer('gedcom_chunk_id', true);
            $table->integer('gedcom_id');
            $table->binary('chunk_data');
            $table->boolean('imported')->default(0);

            $table->index(['gedcom_id', 'imported']);

            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
        });

        // See https://github.com/laravel/framework/issues/3544
        if (DB::connection()->getDriverName() === 'mysql') {
            $table = DB::connection()->getSchemaGrammar()->wrapTable('gedcom_chunk');
            $sql   = 'ALTER TABLE ' . $table . ' MODIFY chunk_data LONGBLOB';
            DB::connection()->statement($sql);
        }
    }
1365817
public function up() {
		$db = Database::get();
		$columns = $db->get_column("SHOW COLUMNS FROM transaction");
	  if (in_array('parallel', $columns) == false) {
	    $db->query("ALTER TABLE `transaction`
	          ADD `parallel` tinyint(4) NOT NULL,
	          ADD `retry_interval` int NOT NULL AFTER `parallel`;");
	  }
	}
1034366
def up(tag, sql, revision):
    
    alembic_command.upgrade(
        config=get_config(),
        revision=revision,
        sql=sql,
        tag=tag
    )
1182811
public function upgradeDatabase()
    {
        // image resizing options
        $this->createSinglePage('/dashboard/system/files/image_uploading', 'Image Uploading');

        // background size/position
        \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema([
            'StyleCustomizerInlineStyleSets',
        ]);

        $this->refreshBlockType('image_slider');

        $this->refreshBlockType('youtube');

        $this->refreshBlockType('autonav');
    }
1201083
def upgrade():
    """"""
    op.create_table(
        'crawler_job',
        sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
        sa.Column('job_id', UUIDType, index=True),
        sa.Column('spider', sa.String(255), index=True),
        sa.Column('workflow', sa.String(255), index=True),
        sa.Column('results', sa.Text, nullable=True),
        sa.Column(
            'status',
            ChoiceType(JobStatus, impl=sa.String(10)),
            nullable=False
        ),
        sa.Column('logs', sa.Text, nullable=True),
        sa.Column(
            'scheduled',
            sa.DateTime,
            default=datetime.now,
            nullable=False,
            index=True
        )
    )

    op.create_table(
        'crawler_workflows_object',
        sa.Column('job_id', UUIDType, primary_key=True),
        sa.Column(
            'object_id',
            sa.Integer,
            sa.ForeignKey(
                'workflows_object.id',
                ondelete="CASCADE",
                onupdate="CASCADE",
            ),
            primary_key=True
        )
    )
410553
def upgrade():
    """"""
    op.create_table(
        'accounts_role',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=80), nullable=True),
        sa.Column('description', sa.String(length=255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name')
    )
    op.create_table(
        'accounts_user',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('email', sa.String(length=255), nullable=True),
        sa.Column('password', sa.String(length=255), nullable=True),
        sa.Column('active', sa.Boolean(name='active'), nullable=True),
        sa.Column('confirmed_at', sa.DateTime(), nullable=True),
        sa.Column('last_login_at', sa.DateTime(), nullable=True),
        sa.Column('current_login_at', sa.DateTime(), nullable=True),
        sa.Column('last_login_ip',
                  sqlalchemy_utils.types.ip_address.IPAddressType(),
                  nullable=True),
        sa.Column('current_login_ip',
                  sqlalchemy_utils.types.ip_address.IPAddressType(),
                  nullable=True),
        sa.Column('login_count', sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('email')
    )
    op.create_table(
        'accounts_user_session_activity',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('sid_s', sa.String(length=255), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['user_id'], [u'accounts_user.id'],
            name='fk_accounts_session_activity_user_id',
        ),
        sa.PrimaryKeyConstraint('sid_s')
    )
    op.create_table(
        'accounts_userrole',
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('role_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['role_id'], ['accounts_role.id'],
            name='fk_accounts_userrole_role_id',
        ),
        sa.ForeignKeyConstraint(
            ['user_id'], ['accounts_user.id'],
            name='fk_accounts_userrole_user_id',
        ),
    )
    with op.batch_alter_table('transaction') as batch_op:
        batch_op.add_column(sa.Column(
            'user_id',
            sa.Integer(),
            sa.ForeignKey('accounts_user.id'),
            nullable=True,
        ))
        batch_op.create_index(
            op.f('ix_transaction_user_id'), ['user_id'], unique=False
        )
186053
def update(self, *args, **kwargs):
        """"""
        self._extend(args, kwargs, 'update', self._update_items)
934435
def update(self, db):
        

        self.lock.acquire()
        update_db(self.db, db.db)
        self.lock.release()
1258043
def do_upgrade(self):
        """"""
        sql = text('delete from upgrade where upgrade = :upgrade')
        db.engine.execute(
            sct(ql, upgrade='invenio_upgrader_2015_11_12_innodb_removal'))
572398
def update(table, values, where=(), **kwargs):
    """"""
    where = dict(where, **kwargs).items()
    sql, args = makeSQL("UPDATE", table, values=values, where=where)
    return execute(sql, args).rowcount
396075
public function upgradeDatabase()
    {
        $this->connection->executeQuery("UPDATE btSearch SET postTo_cID = NULL WHERE postTo_cID IS NOT NULL AND postTo_cID = ''");
        foreach ([
            "postTo_cID NOT REGEXP '^[1-9][0-9]*$'",
            'IFNULL(postTo_cID + 0, 0) < 1',
            'IFNULL(CAST(postTo_cID AS SIGNED), 0) < 1',
        ] as $try) {
            try {
                $this->connection->executeQuery('UPDATE btSearch SET postTo_cID = NULL WHERE postTo_cID IS NOT NULL AND ' . $try);
                break;
            } catch (Exception $foo) {
            }
        }
        $this->refreshBlockType('search');
    }
611280
def update(self,record,**kw):
        """"""
        vals = self._make_sql_params(kw)
        sql = "UPDATE %s SET %s WHERE rowid=?" %(self.name,
            ",".join(vals))
        self.cursor.execute(sql,kw.values()+[record['__id__']])
702590
def db_upgrade(version=None):
    """"""
    v1 = get_db_version()
    migrate_api.upgrade(url=db_url, repository=db_repo, version=version)
    v2 = get_db_version()

    if v1 == v2:
        print 'Database already up-to-date.'
    else:
        print 'Upgraded: %s ... %s' % (v1, v2)
592718
public function upgradeDatabase()
    {
        Page::getByPath('/dashboard/system/backup')->delete();
        Page::getByPath('/dashboard/system/backup/backup')->delete();
        Page::getByPath('/dashboard/system/backup/update')->delete();

        $this->createSinglePage('/dashboard/system/update', 'Update concrete5');

        $this->createSinglePage('/dashboard/system/update/update', 'Apply Update', ['meta_keywords' => 'upgrade, new version, update']);
    }
479247
def upgrade():
    """"""
    op.create_table(
        'communities_community',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('id', sa.String(length=100), nullable=False),
        sa.Column('id_user', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=255), nullable=False),
        sa.Column('description', sa.Text(), nullable=False),
        sa.Column('page', sa.Text(), nullable=False),
        sa.Column('curation_policy', sa.Text(), nullable=False),
        sa.Column('last_record_accepted', sa.DateTime(), nullable=False),
        sa.Column('logo_ext', sa.String(length=4), nullable=True),
        sa.Column('ranking', sa.Integer(), nullable=False),
        sa.Column('fixed_points', sa.Integer(), nullable=False),
        sa.Column('deleted_at', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['id_user'], [u'accounts_user.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_table(
        'communities_community_record',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('id_community', sa.String(length=100), nullable=False),
        sa.Column('id_record', sqlalchemy_utils.types.uuid.UUIDType(),
                  nullable=False),
        sa.Column('id_user', sa.Integer(), nullable=True),
        sa.Column('expires_at', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(
            ['id_community'], ['communities_community.id'],
            name='fk_communities_community_record_id_community',
        ),
        sa.ForeignKeyConstraint(['id_record'], [u'records_metadata.id'], ),
        sa.ForeignKeyConstraint(['id_user'], [u'accounts_user.id'], ),
        sa.PrimaryKeyConstraint('id_community', 'id_record')
    )
    op.create_table(
        'communities_featured_community',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('id_community', sa.String(length=100), nullable=False),
        sa.Column('start_date', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ['id_community'], [u'communities_community.id'],
            name='fk_communities_featured_community_id_community',
        ),
        sa.PrimaryKeyConstraint('id')
    )