Migrating the database from legacy flask app to django


This Content is from Stack Overflow. Question asked by se6

Hello i have an existing app made in Flask, it consist of simple database but it doesn’t have migrations (flask-migrate) ever since and the data grows more. If i enable the migrations on django, could it screw the datas?

and in case if i disable the migrations, can django writes up like the old existing ones?

Here’s my old db model (FLASK)

from database.db import db
class users(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(255), unique=True)
    project = db.Column(db.String(255))
    reason = db.Column(db.String(255))
    timestamp = db.Column(db.DateTime, default=now)

And this is my new one (DJANGO)

from django.db import models as db
class users(db.Model):
    class Meta:
        managed = False
    id = db.AutoField(primary_key=True)
    name = db.CharField(max_length=255, unique=True)
    project = db.CharField(max_length=255)
    reason = db.CharField(max_length=255)
    timestamp = db.DateTimeField(auto_now_add=True)


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?