# Error: There is already an object named 'django\_migrations' in the database.

**URL:** <https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607>\
**Category:** Using the ORM\
**Created:** [August 6, 2024, 11:42am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607 "2024-08-06T11:42:16Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![kelvinho8](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kelvinho8/32/2853_2.png) [@kelvinho8](https://forum.djangoproject.com/u/kelvinho8)\
**Post date:** [August 7, 2024, 7:08am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/21 "2024-08-07T07:08:04Z")

</div>

what I meant was adding this new database source to django project.

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 7, 2024, 7:26am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/22 "2024-08-07T07:26:16Z")

</div>

yes. because you are adding new db, there is no data in msql db.

---

<div class="post-metadata">

**Author:** ![kelvinho8](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kelvinho8/32/2853_2.png) [@kelvinho8](https://forum.djangoproject.com/u/kelvinho8)\
**Post date:** [August 7, 2024, 7:40am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/23 "2024-08-07T07:40:36Z")

</div>

‘mssql’ is a legacy database with loads of data in it 🙂 that’s the reason why I said deleting the DB is not an option

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 7, 2024, 7:48am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/24 "2024-08-07T07:48:46Z")

</div>

If you use a connection to a DB where data is added in a different way, use the managed option.

> **[Model Meta options | Django documentation](https://docs.djangoproject.com/en/5.0/ref/models/options/#managed)**
>
> The web framework for perfectionists with deadlines.

---

<div class="post-metadata">

**Author:** ![kelvinho8](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kelvinho8/32/2853_2.png) [@kelvinho8](https://forum.djangoproject.com/u/kelvinho8)\
**Post date:** [August 7, 2024, 7:54am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/25 "2024-08-07T07:54:20Z")

</div>

So do you mean I need to add managed=True in model table because of the legacy database that I used? But the default value of managed option is already True.

I am not trying to read a legacy table from ‘mssql’, but instead try to migrate a newly create model table to it.

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 8, 2024, 12:09am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/26 "2024-08-08T00:09:12Z")

</div>

What do you mean, editing a model that declares to only use reads?

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 8, 2024, 1:45am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/27 "2024-08-08T01:45:56Z")

</div>

What do you mean, editing a model that declares to only use reads?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 8, 2024, 1:49am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/28 "2024-08-08T01:49:36Z")

</div>

> [@kelvinho8](#):
>
> My current database status are that  
> The django\_migrations table already created and existed in ‘default’ sqlite db after initially setup.  
> The django\_migrations table is not existed in ‘mssql’ sql server db and I’m trying to add this new database source to my existing django project.

I’m still a little confused here.

If the database already exists, and has data in it, why are you trying to run migrations on it? Migrations are only used when you’re looking to alter the schema.  
They’re not needed with existing data.

Also, if you’re getting an error with the migration, please post the complete error with the traceback. It is possible that there’s a different root cause than the obvious error being displayed.

---

<div class="post-metadata">

**Author:** ![kelvinho8](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kelvinho8/32/2853_2.png) [@kelvinho8](https://forum.djangoproject.com/u/kelvinho8)\
**Post date:** [August 8, 2024, 9:56am UTC](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607/29 "2024-08-08T09:56:43Z")

</div>

Hi @KenWhitesell ,

‘mssql’ is a legacy database which already contains lots of tables that have been created out of django scope. The reason why I still need to have migrate to this ‘mssql’ db is that when I created a new model table in django, I’d migrate and store this newly created model in ‘mssql’ db and treat ‘mssql’ db as data storage database. The ‘default’ sqlite db will only store admin, contenttype, auth, etc. information and be treated as admin database only.

By the way, I kind of found the root cause. While running `python manage.py migrate --database mssql`, the table `django_migrations` created in mssql db is named as `[database_name].[my_username].[django_migrations]`. But I guess django is expected to have `dbo` as schema instead `[database_name].[dbo].[django_migrations]`. But it’s my blind guess, not 100% sure that’s the root cause.

Given my guess was correct, would it be possible that we could define django to use `dbo` schema instead of my user name?

Thank you for your response.

Kelvin

[Previous page](https://forum.djangoproject.com/t/error-there-is-already-an-object-named-django-migrations-in-the-database/33607.md?page=1)
