Skip to content

python manage.py migrate throws error for legacy MicrosoftSQL server database having tables in different schemas #218

Open
@harshacheemakurt

Description

@harshacheemakurt

django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The specified
schema name "dbo" either does not exist or you do not have permission to use it. (2760) (SQLExecDirectW)'))

Note able to connect to data base and inspect db works partially

My Django models.py file

class Afactor(models.Model):
factorid = models.IntegerField(db_column='FactorId') # Field name made lowercase.
year = models.DateField(db_column='YearEnd', blank=True, null=True) # Field name made lowercase.
name = models.CharField(db_column='Name', max_length=500, blank=True, null=True) # Field name made lowercase.
factor = models.CharField(db_column='Factor', max_length=1000, blank=True, null=True) # Field name made lowercase.
tag = models.CharField(db_column='Tag', max_length=100, blank=True, null=True) # Field name made lowercase.

class Meta:
    #   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
    managed = False
    # db_table = 'your_schema\".\"your_table'
    db_table = 'My_Schema_name].[Afactor'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions