def test_sync_triggers(self):
     sync_trigger(self.connection, "article_version")
     assert 'DROP TRIGGER IF EXISTS article_trigger ON "article"' in QueryPool.queries[-4]
     assert "DROP FUNCTION " in QueryPool.queries[-3]
     assert "CREATE OR REPLACE FUNCTION " in QueryPool.queries[-2]
     assert "CREATE TRIGGER " in QueryPool.queries[-1]
     sync_trigger(self.connection, "article_version")
def upgrade():
    for table in ['file', 'file_version']:
        op.add_column(table, sa.Column('sha512',
                                        sa.String(length=128),
                                        server_default=None,
                                        nullable=True))
        op.add_column(table, sa.Column('sha512_checked_at',
                                        sa.DateTime(),
                                        server_default=None,
                                        nullable=True))
        op.add_column(table, sa.Column('sha512_created_at',
                                        sa.DateTime(),
                                        server_default=None,
                                        nullable=True))
        op.add_column(table, sa.Column('sha512_ok',
                                        sa.Boolean(),
                                        server_default=None,
                                        nullable=True))
        # file size
        op.add_column(table, sa.Column('size',
                                        sa.BigInteger(),
                                        server_default=None,
                                        nullable=True))
    # sync triggers, for explanation see
    # http://sqlalchemy-continuum.readthedocs.io/en/latest/native_versioning.html
    # careful works only with our fork of sqlalchemy-continuum because of #115
    # https://github.com/kvesteri/sqlalchemy-continuum/issues/115
    conn = op.get_bind()
    sync_trigger(conn, 'file_version')
示例#3
0
 def test_sync_triggers(self):
     sync_trigger(self.connection, 'article_version')
     assert ('DROP TRIGGER IF EXISTS article_trigger ON "article"'
             in QueryPool.queries[-4])
     assert 'DROP FUNCTION ' in QueryPool.queries[-3]
     assert 'CREATE OR REPLACE FUNCTION ' in QueryPool.queries[-2]
     assert 'CREATE TRIGGER ' in QueryPool.queries[-1]
     sync_trigger(self.connection, 'article_version')
 def test_sync_triggers(self):
     next_index = len(QueryPool.queries)
     sync_trigger(self.connection, 'article')
     assert ('DROP TRIGGER IF EXISTS article_trigger ON "article"'
             in QueryPool.queries[next_index])
     assert 'DROP FUNCTION ' in QueryPool.queries[next_index + 1]
     assert 'CREATE OR REPLACE FUNCTION ' in QueryPool.queries[-2]
     assert 'CREATE TRIGGER ' in QueryPool.queries[-1]
     sync_trigger(self.connection, 'article')
def downgrade():
    for table in ['file', 'file_version']:
        op.drop_column(table, 'sha512')
        op.drop_column(table, 'sha512_created_at')
        op.drop_column(table, 'sha512_checked_at')
        op.drop_column(table, 'sha512_ok')
        # file size
        op.drop_column(table, 'size')
    conn = op.get_bind()
    sync_trigger(conn, 'file_version')
示例#6
0
def downgrade():
    for table in ['file', 'file_version']:
        op.drop_column(table, 'sha512')
        op.drop_column(table, 'sha512_created_at')
        op.drop_column(table, 'sha512_checked_at')
        op.drop_column(table, 'sha512_ok')
        # file size
        op.drop_column(table, 'size')
    conn = op.get_bind()
    sync_trigger(conn, 'file_version')
示例#7
0
    def test_sync_triggers(self):
        mock_manager = VersioningManager()
        mock_manager.options = {
            'table_name': 'custom_%s_versioning_table_scheme'
        }

        sync_trigger(self.connection,
                     'custom_article_versioning_table_scheme',
                     versioning_manager=mock_manager)
        assert ('DROP TRIGGER IF EXISTS article_trigger ON "article"'
                in QueryPool.queries[-4])
        assert 'DROP FUNCTION ' in QueryPool.queries[-3]
        assert 'CREATE OR REPLACE FUNCTION ' in QueryPool.queries[-2]
        assert 'CREATE TRIGGER ' in QueryPool.queries[-1]

        sync_trigger(self.connection,
                     'custom_article_versioning_table_scheme',
                     versioning_manager=mock_manager)
示例#8
0
def upgrade():
    for table in ['file', 'file_version']:
        op.add_column(
            table,
            sa.Column('sha512',
                      sa.String(length=128),
                      server_default=None,
                      nullable=True))
        op.add_column(
            table,
            sa.Column('sha512_checked_at',
                      sa.DateTime(),
                      server_default=None,
                      nullable=True))
        op.add_column(
            table,
            sa.Column('sha512_created_at',
                      sa.DateTime(),
                      server_default=None,
                      nullable=True))
        op.add_column(
            table,
            sa.Column('sha512_ok',
                      sa.Boolean(),
                      server_default=None,
                      nullable=True))
        # file size
        op.add_column(
            table,
            sa.Column('size',
                      sa.BigInteger(),
                      server_default=None,
                      nullable=True))
    # sync triggers, for explanation see
    # http://sqlalchemy-continuum.readthedocs.io/en/latest/native_versioning.html
    # careful works only with our fork of sqlalchemy-continuum because of #115
    # https://github.com/kvesteri/sqlalchemy-continuum/issues/115
    conn = op.get_bind()
    sync_trigger(conn, 'file_version')
 def test_sync_triggers(self):
     sync_trigger(self.connection, 'article_version')
     assert 'DROP FUNCTION ' in QueryPool.queries[-4]
     assert 'DROP TRIGGER ' in QueryPool.queries[-3]
     assert 'CREATE OR REPLACE FUNCTION ' in QueryPool.queries[-2]
     assert 'CREATE TRIGGER ' in QueryPool.queries[-1]
示例#10
0
 def test_sync_trigger_failure_bad_format(self):
     with pytest.raises(ValueError):
         sync_trigger(self.connection,
                      'custom_article_versioning_table_scheme',
                      versioning_manager=None)
 def test_drop_triggers_using_sync(self):
     self.connection.execute('DROP TABLE IF EXISTS article')
     sync_trigger(self.connection, 'article')
     assert ('DROP TRIGGER IF EXISTS article_trigger ON "article"'
             in QueryPool.queries[-3])
     assert 'DROP FUNCTION ' in QueryPool.queries[-2]