Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django does not migrate app

I'm working on a django project for learning purpose. I've created an app organization and installed it. When I run python manage.py makemigrations organization it works fine shows the changes.

Migrations for 'organization':
  organization/migrations/0001_initial.py:
    - Create model Organization
    - Create model Principle

But when I run python manage.py migrate organization it doesn't migrate and shows no changes to apply.

Operations to perform:
  Apply all migrations: organization
Running migrations:
  No migrations to apply.

I'm using postgresql and tried drop owned by user_name; after deleting all migrations folders. But still doesn't work. It shows every time the same thing. How to resolve this ?

Environment:
OS version Ubuntu 16.04
Django version 1.10.3
PostgreSQL version 9.5.7

organization/models.py

from django.db import models
from django.contrib.postgres.fields import JSONField    

class Principle(models.Model):
    name = models.CharField(max_length=256)
    description = models.CharField(max_length=256)
    contact_no = models.CharField(max_length=256)
    status = models.BooleanField()


class Organization(models.Model):
    name = models.CharField(max_length=256)
    liceneses = [
        ('pvt','Private Limited',),
        ('pub','Public Limited',),
        ('part','Partnership',),
        ('prop','proprietary',)
    ]

    licenese_type = models.CharField(max_length=10, choices=liceneses)
    key_person_name = models.CharField(max_length=256)
    key_person_position = models.CharField(max_length=256)
    key_person_contact_no = models.CharField(max_length=45)
    primary_organization_contact = models.CharField(max_length=45)
    organization_address = models.TextField()
    additional_info = JSONField()
    date_of_registration = models.CharField(max_length=45)
    status = models.BooleanField()
like image 739
MD. Khairul Basar Avatar asked Dec 05 '25 19:12

MD. Khairul Basar


1 Answers

in these case delete all the migrations files from migration folder except __init__.py file for all apps, make sure you have the apps in the installed apps

then delete the database tables

NOTE: Be careful to backup important FILES when you delete your DATABASE !

run python manage.py migrate
run python manage.py makemigrations
run python manage.py migrate
like image 133
Exprator Avatar answered Dec 08 '25 12:12

Exprator



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!