sqlalchemy.Unicode

Here are the examples of the python api sqlalchemy.Unicode taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

193 Examples 7

Example 1

View license
def upgrade():
    op.add_column(
        'snapshot',
        sa.Column('resource_name', sa.Unicode(length=64), nullable=False))
    op.add_column(
        'snapshot',
        sa.Column('resource_pkey', sa.Integer(), nullable=False))
    op.create_index(
        op.f('ix_snapshot_resource_pkey'),
        'snapshot',
        ['resource_pkey'],
        unique=False)
    op.drop_index('ix_snapshot_resource_id', table_name='snapshot')
    op.drop_column('snapshot', 'resource_id')
    op.drop_column('snapshot', 'resource_repr')

Example 2

Project: sqlalchemy
Source File: test_resultset.py
View license
    @classmethod
    def setup_class(cls):
        global t, t2, metadata
        metadata = MetaData(testing.db)
        t = Table('table', metadata, *[Column('field%d' % fnum, String(50))
                                       for fnum in range(NUM_FIELDS)])
        t2 = Table(
            'table2', metadata, *
            [Column('field%d' % fnum, Unicode(50))
             for fnum in range(NUM_FIELDS)])

Example 3

Project: sqlalchemy
Source File: test_reflection.py
View license
    def test_string_types(self):
        specs = [
            (String(1), mysql.MSString(1)),
            (String(3), mysql.MSString(3)),
            (Text(), mysql.MSText()),
            (Unicode(1), mysql.MSString(1)),
            (Unicode(3), mysql.MSString(3)),
            (UnicodeText(), mysql.MSText()),
            (mysql.MSChar(1), mysql.MSChar(1)),
            (mysql.MSChar(3), mysql.MSChar(3)),
            (NCHAR(2), mysql.MSChar(2)),
            (mysql.MSNChar(2), mysql.MSChar(2)),
            (mysql.MSNVarChar(22), mysql.MSString(22),),
        ]
        self._run_test(specs, ['length'])

Example 4

View license
def upgrade():
    op.drop_table('unitparameterunit')
    op.drop_table('unitparameterunit_history')

    with op.batch_alter_table('ref_history') as b:
        b.add_column(sa.Column('language_note', sa.Unicode))
        b.add_column(sa.Column('ca_language_trigger', sa.Unicode))
        b.add_column(sa.Column('ca_doctype_trigger', sa.Unicode))

Example 5

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('account', sa.Column('facebook_id', sa.Unicode(), nullable=True))
    op.add_column('account', sa.Column('full_name', sa.Unicode(), nullable=True))
    op.add_column('account', sa.Column('twitter_id', sa.Unicode(), nullable=True))
    op.create_index('ix_property_entity_id', 'property', ['entity_id'], unique=False)
    op.create_index('ix_property_name', 'property', ['name'], unique=False)
    op.create_index('ix_property_relation_id', 'property', ['relation_id'], unique=False)
    op.create_index('ix_relation_schema_id', 'relation', ['schema_id'], unique=False)
    op.create_index('ix_relation_source_id', 'relation', ['source_id'], unique=False)
    op.create_index('ix_relation_target_id', 'relation', ['target_id'], unique=False)

Example 6

View license
def upgrade():
    op.add_column('releases', sa.Column('branch', sa.Unicode(length=10)))
    op.create_unique_constraint(None, 'releases', ['branch'])

    engine = op.get_bind()
    Session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    Session.configure(bind=engine)
    db = Session()
    Base.metadata.bind = engine

    with transaction.manager:
        for release in db.query(Release).all():
            release.branch = release.name.lower()

Example 7

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('laboratories', 'laboratory_id',
               existing_type=mysql.VARCHAR(length=255),
               nullable=False)
    op.alter_column('laboratories', 'name',
               existing_type=mysql.VARCHAR(length=255),
               nullable=False)
    op.add_column('rlmss', sa.Column('name', sa.Unicode(length=50), nullable=True))

Example 8

Project: coaster
Source File: sqlalchemy.py
View license
    @declared_attr
    def name(cls):
        """The URL name of this object, unique across all instances of this model"""
        if cls.__name_blank_allowed__:
            return Column(Unicode(cls.__name_length__), nullable=False, unique=True)
        else:
            return Column(Unicode(cls.__name_length__), CheckConstraint("name <> ''"), nullable=False, unique=True)

Example 9

Project: coaster
Source File: sqlalchemy.py
View license
    @declared_attr
    def name(cls):
        """The URL name of this object, unique within a parent container"""
        if cls.__name_blank_allowed__:
            return Column(Unicode(cls.__name_length__), nullable=False)
        else:
            return Column(Unicode(cls.__name_length__), CheckConstraint("name <> ''"), nullable=False)

Example 10

Project: coaster
Source File: sqlalchemy.py
View license
    @declared_attr
    def name(cls):
        """The URL name of this object, non-unique"""
        if cls.__name_blank_allowed__:
            return Column(Unicode(cls.__name_length__), nullable=False)
        else:
            return Column(Unicode(cls.__name_length__), CheckConstraint("name <> ''"), nullable=False)

Example 11

Project: coaster
Source File: sqlalchemy.py
View license
    @declared_attr
    def name(cls):
        """The URL name of this instance, non-unique"""
        if cls.__name_blank_allowed__:
            return Column(Unicode(cls.__name_length__), nullable=False)
        else:
            return Column(Unicode(cls.__name_length__), CheckConstraint("name <> ''"), nullable=False)

Example 12

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('proposal', sa.Column('blog_post', sa.Unicode(250), server_default=u'', nullable=False))
    op.alter_column('proposal', 'blog_post', server_default=None)
    op.add_column('proposal', sa.Column('preview_video', sa.Unicode(250), server_default=u'', nullable=False))
    op.alter_column('proposal', 'preview_video', server_default=None)

Example 13

View license
def upgrade():
    proposal_space = table('proposal_space',
        column('name', sa.Unicode(250)),
        column('legacy_name', sa.Unicode(250)))

    proposal = table('proposal',
        column('id', sa.Integer),
        column('url_id', sa.Integer))

    op.add_column('proposal_space', sa.Column('legacy_name', sa.Unicode(250), nullable=True))
    op.execute(proposal_space.update().values({'legacy_name': proposal_space.c.name}))
    op.create_unique_constraint('proposal_space_legacy_name_key', 'proposal_space', ['legacy_name'])

    op.add_column('proposal', sa.Column('url_id', sa.Integer(), nullable=True))
    op.execute(proposal.update().values({'url_id': proposal.c.id}))
    op.alter_column('proposal', 'url_id', nullable=False)
    op.create_unique_constraint('proposal_proposal_space_id_url_id_key', 'proposal', ['proposal_space_id', 'url_id'])

Example 14

View license
def upgrade():
    op.alter_column('ticket_client', 'client_event_id', new_column_name='client_eventid')
    op.alter_column('ticket_client', 'client_id', new_column_name='clientid')

    op.drop_constraint('sync_ticket_ticket_client_id', 'sync_ticket', type_='foreignkey')
    op.create_foreign_key('sync_ticket_ticket_client_id_fkey', 'sync_ticket', 'ticket_client', ['ticket_client_id'], ['id'])

    op.drop_constraint('event_proposal_space_id_name', 'event', type_='unique')
    op.create_unique_constraint('event_proposal_space_id_name_key', 'event', ['proposal_space_id', 'name'])

    op.drop_constraint(u'contact_exchange_user_id_proposal_space_id_participant_id_pk', 'contact_exchange', type_='unique')
    op.create_primary_key(u'contact_exchange_user_id_proposal_space_id_participant_id_key', 'contact_exchange', ['user_id', 'proposal_space_id', 'participant_id'])

    op.drop_constraint(u'sync_ticket_proposal_space_id_order_no_ticket_no', 'sync_ticket', type_='unique')
    op.create_unique_constraint(u'sync_ticket_proposal_space_id_order_no_ticket_no_key', 'sync_ticket', ['proposal_space_id', 'order_no', 'ticket_no'])

    op.alter_column('participant', 'email', type_=sa.Unicode(length=254))

Example 15

View license
def downgrade():
    op.alter_column('ticket_client', 'client_eventid', new_column_name='client_event_id')
    op.alter_column('ticket_client', 'clientid', new_column_name='client_id')

    op.drop_constraint('sync_ticket_ticket_client_id_fkey', 'sync_ticket', type_='foreignkey')
    op.create_foreign_key('sync_ticket_ticket_client_id', 'sync_ticket', 'ticket_client', ['ticket_client_id'], ['id'])

    op.drop_constraint('event_proposal_space_id_name_key', 'event', type_='unique')
    op.create_unique_constraint('event_proposal_space_id_name', 'event', ['proposal_space_id', 'name'])

    op.drop_constraint(u'contact_exchange_user_id_proposal_space_id_participant_id_key', 'contact_exchange', type_='unique')
    op.create_primary_key(u'contact_exchange_user_id_proposal_space_id_participant_id_pk', 'contact_exchange', ['user_id', 'proposal_space_id', 'participant_id'])

    op.drop_constraint(u'sync_ticket_proposal_space_id_order_no_ticket_no_key', 'sync_ticket', type_='unique')
    op.create_unique_constraint(u'sync_ticket_proposal_space_id_order_no_ticket_no', 'sync_ticket', ['proposal_space_id', 'order_no', 'ticket_no'])

    op.alter_column('participant', 'email', type_=sa.Unicode(length=80))

Example 16

View license
def upgrade():
    op.add_column('useremail', sa.Column('domain', sa.Unicode(length=253), nullable=True))
    op.execute(sa.text("UPDATE \"useremail\" SET domain=substring(substring(email from '@.*$') from 2)"))
    op.alter_column('useremail', 'domain', nullable=False)
    op.create_index(op.f('ix_useremail_domain'), 'useremail', ['domain'], unique=False)
    op.add_column('useremailclaim', sa.Column('domain', sa.Unicode(length=253), nullable=True))
    op.execute(sa.text("UPDATE \"useremailclaim\" SET domain=substring(substring(email from '@.*$') from 2)"))
    op.alter_column('useremailclaim', 'domain', nullable=False)
    op.create_index(op.f('ix_useremailclaim_domain'), 'useremailclaim', ['domain'], unique=False)

Example 17

Project: ydbf
Source File: dbf2sa.py
View license
def _create_column(dbf_name, dbf_type, dbf_length, dbf_decimal):
    """
    Return SQLAlchemy column for specified dbf field
    """
    if dbf_type == 'C':
        sa_type = sa.Unicode(dbf_length)
    elif dbf_type == 'D':
        sa_type = sa.Date
    elif dbf_type == 'N':
        if dbf_decimal == 0:
            sa_type = sa.Integer
        else:
            # WARN: all decimals are converted to float, may loose some info
            sa_type = sa.Float
    elif dbf_type == 'L':
        sa_type = sa.Boolean
    else:
        raise ValueError("Dosen't know how convert %r type" % dbf_type)
    return sa.Column(_get_column_name(dbf_name), sa_type)

Example 18

View license
    def create_models(self):
        class User(self.Model):
            __tablename__ = 'user'
            __versioned__ = copy(self.options)

            first_name = sa.Column(sa.Unicode(255), primary_key=True)
            last_name = sa.Column(sa.Unicode(255), primary_key=True)
            email = sa.Column(sa.Unicode(255))

        self.User = User

Example 19

View license
    def create_models(self):
        class User(self.Model):
            __tablename__ = 'user'
            __versioned__ = copy(self.options)

            first_name = sa.Column(sa.Unicode(255), primary_key=True)
            last_name = sa.Column(sa.Unicode(255), primary_key=True)
            email = sa.Column(sa.Unicode(255))

        self.User = User

Example 20

View license
    def create_models(self):
        class User(self.Model):
            __tablename__ = 'user'
            __versioned__ = {
                'base_classes': (self.Model, )
            }

            id = sa.Column(sa.Unicode(255), primary_key=True)
            name = sa.Column(sa.Unicode(255), nullable=False)

        self.User = User

Example 21

View license
    def create_models(self):
        class User(self.Model):
            __tablename__ = 'user'
            __versioned__ = {
                'base_classes': (self.Model, )
            }

            id = sa.Column(sa.Unicode(255), primary_key=True)
            name = sa.Column(sa.Unicode(255), nullable=False)

        self.User = User

Example 22

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
                'auto_create_locales': True,
                'fallback_locale': lambda self: self.locale or 'en'
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 23

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
                'auto_create_locales': True,
                'fallback_locale': lambda self: self.locale or 'en'
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 24

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
                'auto_create_locales': True,
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

            def get_locale(self):
                return 'en'

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 25

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
                'auto_create_locales': True,
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

            def get_locale(self):
                return 'en'

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 26

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

            @hybrid_property
            def locale(self):
                return self._locale or 'en'

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 27

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

            @hybrid_property
            def locale(self):
                return self._locale or 'en'

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 28

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
                'auto_create_locales': True,
                'exclude_hybrid_properties': ['word_count'],
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 29

View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
                'auto_create_locales': True,
                'exclude_hybrid_properties': ['word_count'],
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 30

View license
    def test_raises_exception(self):
        with raises(ImproperlyConfigured):
            class ArticleTranslation(translation_base(self.Article)):
                __tablename__ = 'article_translation'

                name = sa.Column(sa.Unicode(255))
            self.Article()

Example 31

View license
    def test_raises_exception(self):
        with raises(ImproperlyConfigured):
            class ArticleTranslation(translation_base(self.Article)):
                __tablename__ = 'article_translation'

                name = sa.Column(sa.Unicode(255))
            self.Article()

Example 32

Project: sqlalchemy-i18n
Source File: __init__.py
View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

            @hybrid_property
            def locale(self):
                return 'en'

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 33

Project: sqlalchemy-i18n
Source File: __init__.py
View license
    def create_models(self):
        class Article(ClassicBase, Translatable):
            __translatable__ = {
                'locales': self.locales,
            }
            __translated_columns__ = [
                sa.Column('name', sa.Unicode(255)),
                sa.Column('content', sa.UnicodeText),
            ]

            @hybrid_property
            def locale(self):
                return 'en'

        class ArticleTranslation(ClassicBase, BaseTranslationMixin):
            __parent_class__ = Article

        self.Article = Article
        self.ArticleTranslation = ArticleTranslation

Example 34

View license
    @pytest.fixture
    def User(self, Base):
        class User(Base):
            __tablename__ = 'user'
            first_name = sa.Column(sa.Unicode(255), primary_key=True)
            last_name = sa.Column(sa.Unicode(255), primary_key=True)
        return User

Example 35

View license
    @pytest.fixture
    def User(self, Base):
        class User(Base):
            __tablename__ = 'user'
            first_name = sa.Column(sa.Unicode(255), primary_key=True)
            last_name = sa.Column(sa.Unicode(255), primary_key=True)
        return User

Example 36

View license
    @pytest.fixture
    def User(self, Base):
        class User(Base):
            __tablename__ = 'user'
            first_name = sa.Column(sa.Unicode(255), primary_key=True)
            last_name = sa.Column(sa.Unicode(255), primary_key=True)
        return User

Example 37

View license
    @pytest.fixture
    def User(self, Base):
        class User(Base):
            __tablename__ = 'user'
            first_name = sa.Column(sa.Unicode(255), primary_key=True)
            last_name = sa.Column(sa.Unicode(255), primary_key=True)
        return User

Example 38

View license
@pytest.fixture
def EventBase(Base):
    class EventBase(Base):
        __abstract__ = True

        object_type = sa.Column(sa.Unicode(255))
        object_id = sa.Column(sa.Integer, nullable=False)

        @declared_attr
        def object(cls):
            return generic_relationship('object_type', 'object_id')
    return EventBase

Example 39

View license
@pytest.fixture
def EventBase(Base):
    class EventBase(Base):
        __abstract__ = True

        object_type = sa.Column(sa.Unicode(255))
        object_id = sa.Column(sa.Integer, nullable=False)

        @declared_attr
        def object(cls):
            return generic_relationship('object_type', 'object_id')
    return EventBase

Example 40

View license
    def test_unicode_coerces_values_to_unicode_strings(self):
        choices = [('1.0', '1.0'), ('2.0', '2.0')]
        self.init(type_=sa.Unicode(255), info={'choices': choices})
        form = self.form_class(MultiDict({'test_column': '2.0'}))
        assert form.test_column.data == u'2.0'
        assert isinstance(form.test_column.data, six.text_type)

Example 41

View license
    def test_unicode_coerces_values_to_unicode_strings(self):
        choices = [('1.0', '1.0'), ('2.0', '2.0')]
        self.init(type_=sa.Unicode(255), info={'choices': choices})
        form = self.form_class(MultiDict({'test_column': '2.0'}))
        assert form.test_column.data == u'2.0'
        assert isinstance(form.test_column.data, six.text_type)

Example 42

View license
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    text_table = Table(
        'text', meta,
        Column('id', Integer, primary_key=True),
        Column('page_id', Integer, ForeignKey('page.id'), nullable=False),
        Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
        Column('parent_id', Integer, ForeignKey('text.id'), nullable=True),
        Column('variant', Unicode(255), nullable=True),
        Column('title', Unicode(255), nullable=True),
        Column('text', UnicodeText(), nullable=True),
        Column('create_time', DateTime, default=datetime.utcnow),
        Column('delete_time', DateTime)
        )

    wiki = Column('wiki', Boolean, default=False)
    wiki.create(text_table)
    u = text_table.update(values={'wiki': False})
    migrate_engine.execute(u)

Example 43

View license
def upgrade(migrate_engine):
    meta.bind = migrate_engine
    text_table = Table(
        'text', meta,
        Column('id', Integer, primary_key=True),
        Column('page_id', Integer, ForeignKey('page.id'), nullable=False),
        Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
        Column('parent_id', Integer, ForeignKey('text.id'), nullable=True),
        Column('variant', Unicode(255), nullable=True),
        Column('title', Unicode(255), nullable=True),
        Column('text', UnicodeText(), nullable=True),
        Column('create_time', DateTime, default=datetime.utcnow),
        Column('delete_time', DateTime)
        )

    wiki = Column('wiki', Boolean, default=False)
    wiki.create(text_table)
    u = text_table.update(values={'wiki': False})
    migrate_engine.execute(u)

Example 44

View license
def upgrade(migrate_engine):
    metadata.bind = migrate_engine
    text_table = Table('text', metadata,
        Column('id', Integer, primary_key=True),
        Column('page_id', Integer, ForeignKey('page.id'), nullable=False),
        Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
        Column('parent_id', Integer, ForeignKey('text.id'), nullable=True),
        Column('variant', Unicode(255), nullable=True),
        Column('title', Unicode(255), nullable=True),
        Column('text', UnicodeText(), nullable=True),
        Column('wiki', Boolean, default=False),
        Column('create_time', DateTime, default=datetime.utcnow),
        Column('delete_time', DateTime)
        )

    text_table.c.parent_id.alter(name='child_id')

Example 45

View license
def upgrade(migrate_engine):
    # use sqlalchemy-migrate database connection
    metadata.bind = migrate_engine
    # autoload needed tables
    instance_table = Table('instance', metadata, autoload=True)
    # add hierachical columns to the table
    select_child_desc = Column('select_child_description', Unicode(255), default=u'', nullable=True)
    parent = Column('parent_id', Integer, ForeignKey('badge.id', ondelete="CASCADE"),
                    nullable=True)
    # create/recreate the table
    select_child_desc.create(badge_table)
    select_child_desc.alter(nullable=False)
    parent.create(badge_table)

Example 46

View license
def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    table = Table('message', meta, autoload=True)
    col = Column('sender_name', Unicode(255), nullable=True)
    col.create(table)

Example 47

View license
def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    table = Table('badge', meta, autoload=True)
    col = Column('behavior_proposal_sort_order', Unicode(50), nullable=True)
    col.create(table)

Example 48

View license
def upgrade(migrate_engine):
    metadata.bind = migrate_engine

    instance_table = Table('instance', metadata, autoload=True)
    key_column = instance_table.c.key

    key_column.alter(type=Unicode(63))

Example 49

View license
def upgrade(migrate_engine):
    metadata.bind = migrate_engine
    text_table = Table('text', metadata,
        Column('id', Integer, primary_key=True),
        Column('page_id', Integer, ForeignKey('page.id'), nullable=False),
        Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
        Column('parent_id', Integer, ForeignKey('text.id'), nullable=True),
        Column('variant', Unicode(255), nullable=True),
        Column('title', Unicode(255), nullable=True),
        Column('text', UnicodeText(), nullable=True),
        Column('wiki', Boolean, default=False),
        Column('create_time', DateTime, default=datetime.utcnow),
        Column('delete_time', DateTime)
        )

    text_table.c.parent_id.alter(name='child_id')

Example 50

View license
def upgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine

    event_table = Table('event', meta, autoload=True)
    user_table = Table('user', meta, autoload=True)
    watch_table = Table('watch', meta, autoload=True)

    notification_table = Table(
        'notification', meta,
        Column('id', Integer, primary_key=True),
        Column('event_id', Integer, ForeignKey('event.id'), nullable=False),
        Column('event_type', Unicode(255), nullable=True),
        Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
        Column('watch_id', Integer, ForeignKey('watch.id'), nullable=True)
    )

    notification_table.create()