Esempio n. 1
0
    def test_sync_created_fk(self):
        """Test: src table has foreign keys not in dest table"""
        saved = self.dest.foreign_keys['fk_rental_customer']
        pos = self.dest.foreign_keys.index('fk_rental_customer')
        del self.dest.foreign_keys['fk_rental_customer']

        for i, (p,r) in enumerate(syncdb.sync_created_constraints(self.src.foreign_keys, self.dest.foreign_keys)):
            self.assertEqual(p, "ADD CONSTRAINT `fk_rental_customer` FOREIGN KEY `fk_rental_customer` (`customer_id`) REFERENCES `customer` (`customer_id`) ON DELETE RESTRICT ON UPDATE CASCADE")
            self.assertEqual(r, "DROP FOREIGN KEY `fk_rental_customer`")

        self.assertEqual(i, 0)
Esempio n. 2
0
    def test_sync_created_index(self):
        """Test: src table has indexes not in dest table"""
        saved = self.dest.indexes['idx_fk_customer_id']
        pos = self.dest.indexes.index('idx_fk_customer_id')
        del self.dest.indexes['idx_fk_customer_id']

        for i, (p,r) in enumerate(syncdb.sync_created_constraints(self.src.indexes, self.dest.indexes)):
            self.assertEqual(p, "ADD INDEX `idx_fk_customer_id` (`customer_id`) USING BTREE")
            self.assertEqual(r, "DROP INDEX `idx_fk_customer_id`")

        self.assertEqual(i, 0)
    def test_sync_created_index(self):
        """Test: src table has indexes not in dest table"""
        saved = self.dest.indexes['idx_fk_customer_id']
        pos = self.dest.indexes.index('idx_fk_customer_id')
        del self.dest.indexes['idx_fk_customer_id']

        for i, (p, r) in enumerate(
                syncdb.sync_created_constraints(self.src.indexes,
                                                self.dest.indexes)):
            self.assertEqual(
                p,
                "ADD INDEX `idx_fk_customer_id` (`customer_id`) USING BTREE")
            self.assertEqual(r, "DROP INDEX `idx_fk_customer_id`")

        self.assertEqual(i, 0)
    def test_sync_created_fk(self):
        """Test: src table has foreign keys not in dest table"""
        saved = self.dest.foreign_keys['fk_rental_customer']
        pos = self.dest.foreign_keys.index('fk_rental_customer')
        del self.dest.foreign_keys['fk_rental_customer']

        for i, (p, r) in enumerate(
                syncdb.sync_created_constraints(self.src.foreign_keys,
                                                self.dest.foreign_keys)):
            self.assertEqual(
                p,
                "ADD CONSTRAINT `fk_rental_customer` FOREIGN KEY `fk_rental_customer` (`customer_id`) REFERENCES `customer` (`customer_id`) ON DELETE RESTRICT ON UPDATE CASCADE"
            )
            self.assertEqual(r, "DROP FOREIGN KEY `fk_rental_customer`")

        self.assertEqual(i, 0)