are migrations the same regardless of database type?

Skip to first unread message

Anil Felipe Duggirala

Dec 28, 2021, 10:04:21 AM12/28/21
to Django users
I running an app locally using an SQlite database (I have not been able to set up postgresql locally). I am running the same app in Heroku, using Postgresql.
If I run "makemigrations" locally, then push those migrations to Heroku (which is using postgresql), will those migrations be applied correctly by just doing "migrate" on Heroku.
Do the contents of migrations files depend on the database type that is associated to the app when creating the migrations?
thank you,

Anil F

Lars Liedtke

Dec 28, 2021, 10:42:56 AM12/28/21
As far as I know, the migrations are "Python-Code" in themselves, only
defining which tables change in what way. Only when they are being
applied, this is turned into actual database code.

But you can test this easily by creating migrations and look at them. Or
use e.g. a postgres docker container, if my memory is wrong.



Am 28.12.21 um 16:02 schrieb Anil Felipe Duggirala:
-- GmbH
Lars Liedtke

Kaiserallee 13a
76133 Karlsruhe

Tel. +49 721 9109 500

AG Mannheim 108285
Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein


Dec 28, 2021, 12:55:02 PM12/28/21
to Django users
Not exactly.  Migrations try to be generalized across db types, but that doesn't mean that you can be using db-specific features in your models and ORM usage.  Thats one reason its highly, highly recommended to use the same database and version at all layers of your stack.

In other words, if you're using sqlite locally and postgres in deployment, you're opening yourself to the high probability of having to figure something out and finding out that its due to different features in the db.  

Bernard Mallala

Dec 28, 2021, 7:08:16 PM12/28/21
to Django users
Migrations are different depending on your DBMS.
Why? Briefly, here are a few reasons :
  1. RDBMS or DBMS (Database management system) is a software that organizes the data in a database thus allowing for easy management, administration, retrieval and manipulation of data by users or applications. e.g. Oracle, PostgreSQL, Microsoft SQL Server, MySQL , DB2, Informix and so forth.
  2. Database is typically housed within a RDBMS or DBMS. A database is an organized set of logically connected data stored and accessed electronically from a computer system. The information transforms into helpful knowledge, structured and maintained to fit
     user and or application needs. Apart from storing the data itself, a database also keeps the relationships between data points via database normalization rules.
  3. SQL is the basic query language used to operate all the database management systems. There are minor syntax changes amongst different DBMS, but the basic SQL syntax remains largely the same.
    There are many types of SQL commands largely divided into DDL, DML, DCL, TCL, and DQL. Different DBMSs have their own flavor of SQL. For example T-SQL for Microsoft, PL/SQL for Oracle
    There are also many
Django's Object-Relational Mapper (ORM), enables you to interact with your database, like you would with SQL and without having to really know the nuances between one DBS and the other. But if you switch from one DBMS to the next, you will need to generate and run new migrations each time including configuration data etc and this will be disastrous. You therefore, want to use the same DBMS throughout your environments and stack.

Anil Felipe Duggirala

Dec 29, 2021, 8:41:01 AM12/29/21
Thanks to all for your replies. Using the "sqlmigrate" command, as far as I can see, there are no differences between database types.
I asked this question initially because I was unable to set up postgresql locally. I have solved those issues now and will follow your advice on using the same db type for local and production.
thank you all.
Reply all
Reply to author
0 new messages