2

I just wanted to add a field on a model.

class Categories(models.Model):
    #this IDUnique = models.IntegerField(max_length=11, blank=True, null=True)
    IDParent = models.IntegerField(max_length=11, blank=True, null=True)
    Name = models.CharField(max_length=45, blank=False)

When I try migrate:

    Operations to perform:
  Synchronize unmigrated apps: formtools, social_auth, crispy_forms, django_comments
  Apply all migrations: sessions, admin, sites, auth, appname, contenttypes
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.

deleted and migrated again and tried sqlmigrate

   BEGIN;
CREATE TABLE "appname_category__new" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "IDParent" integer NULL, "Name" varchar(45) NOT NULL, "IDUnique" integer NULL);
INSERT INTO "appname_category__new" ("Name", "id", "IDParent") SELECT "Name", "id", "IDParent" FROM "appname_category";
DROP TABLE "appname_category";
ALTER TABLE "appname_category__new" RENAME TO "appname_category";

COMMIT;

And still says

no such column: onlinemarket_categories.IDUnique

Thank you

ciyak
  • 31
  • 4

2 Answers2

0

Why are you running sqlmigrate? The correct command to run migrations is just migrate.

sqlmigrate simply prints the SQL that would be executed in a migration, as the documentation shows.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • yes but it shows when you create table successfully. when i try migrate it doesn't do anything. – ciyak Dec 28 '14 at 21:47
0

Did you try to run python manage.py makemigrations and after that python manage.py migrate or python manage.py syncdb?

Deniz Kaplan
  • 1,549
  • 1
  • 13
  • 18