Esempio n. 1
0
    def test_db_migrate_should_auto_migrate(self, commit_changes):
        # commit_changes is mocked and will never happen, so we can simply
        # rollback the entire migration and not affecting other tests...
        schema = Schema(connection)
        schema.begin()
        try:
            self.call_command(Command(),
                              options={
                                  'interactive': False,
                                  'skip_fixtures': True
                              })

            self.assertTrue(
                schema.sql.index_exists(
                    schema.sql.get_index_name('django_content_type',
                                              'app_label')))
            self.assertEqual(
                'GB',
                schema.sql.get_column_default('testapp_settings',
                                              'country_id'))
        finally:
            schema.rollback()
Esempio n. 2
0
 def setUpClass(cls):
     super(DBMigrateIndexingTestCase, cls).setUpClass()
     cls.schema = Schema(connection)
Esempio n. 3
0
 def setUpClass(cls):
     super(DBMigrateSchemaUpdateFieldDropUniqueConstraintTestCase,
           cls).setUpClass()
     cls.schema = Schema(connection)
     cls.model = TestLikeIndexNotUniqueModel
     cls.table = cls.model._meta.db_table
Esempio n. 4
0
 def setUpClass(cls):
     super(DBMigrateSchemaUpdateFieldDropIndexTestCase, cls).setUpClass()
     cls.schema = Schema(connection)
     cls.model = TestFieldWithoutIndexModel
     cls.table = cls.model._meta.db_table
Esempio n. 5
0
 def test_should_raise_not_implemented_error_for_other_than_postgresql(
         self, connection):
     connection.vendor = 'not-postgresql'
     with self.assertRaisesRegexp(NotImplementedError,
                                  'is currently not supported'):
         Schema(connection)
Esempio n. 6
0
 def test_should_create_postgresql_vendor_for_postgresql(self):
     self.assertIsInstance(Schema(connection).sql, PostgresSql)
Esempio n. 7
0
def get_schema(connection, _verbose):
    """
    Return a representation of the current database schema, which also provides
    methods for manipulating the database schema.
    """
    return Schema(connection, _verbose)