Esempio n. 1
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    from ad2web.notifications.models import NotificationMessage
    from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

    for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
        db.session.add(NotificationMessage(id=event, text=message))

    db.session.commit()
Esempio n. 2
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    # Initialize alembic revision
    from alembic.config import Config
    from alembic import command
    alembic_cfg = Config('alembic.ini')
    command.stamp(alembic_cfg, "head")

    from ad2web.notifications.models import NotificationMessage
    from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

    for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
        db.session.add(NotificationMessage(id=event, text=message))

    db.session.commit()
Esempio n. 3
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    # Initialize alembic revision
    from alembic.config import Config
    from alembic import command
    alembic_cfg = Config('alembic.ini')
    command.stamp(alembic_cfg, "head")

    from ad2web.notifications.models import NotificationMessage
    from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

    for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
        db.session.add(NotificationMessage(id=event, text=message))

    db.session.commit()
    def run(self):
        """Init/reset database."""

        try:
            db.drop_all()
            db.create_all()

            # Initialize alembic revision
            from alembic.config import Config
            from alembic import command
            alembic_cfg = Config('alembic.ini')
            command.stamp(alembic_cfg, "head")

            from ad2web.notifications.models import NotificationMessage
            from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

            for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
                db.session.add(NotificationMessage(id=event, text=message))

            db.session.commit()
        except Exception, err:
            print("Database initialization failed: {0}".format(err))
Esempio n. 5
0
    def run(self):
        """Init/reset database."""

        try:
            db.drop_all()
            db.create_all()

            # Initialize alembic revision
            from alembic.config import Config
            from alembic import command
            alembic_cfg = Config('alembic.ini')
            command.stamp(alembic_cfg, "head")

            from ad2web.notifications.models import NotificationMessage
            from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

            for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
                db.session.add(NotificationMessage(id=event, text=message))

            db.session.commit()
        except Exception, err:
            print("Database initialization failed: {0}".format(err))