Skip to content

Instantly share code, notes, and snippets.

@akki
Last active May 10, 2016 10:06
Show Gist options
  • Save akki/56b6c3cac56073c9bf4d to your computer and use it in GitHub Desktop.
Save akki/56b6c3cac56073c9bf4d to your computer and use it in GitHub Desktop.
#model
class Student(models.Model):
name = models.CharField(max_length=200, db_index=True, unique=True)
branch = models.CharField(max_length=20, db_index=True)
college = models.CharField(max_length=100, unique=True)
year = models.CharField(max_length=100)
def __unicode__(self):
return self.name
# sqlmigrate gives the following output for the above model
'''
BEGIN;
--
-- Create model Student
--
CREATE TABLE "qwe_student" ("id" serial NOT NULL PRIMARY KEY, "name" varchar(200) NOT NULL UNIQUE, "branch" varchar(20) NOT NULL, "college" varchar(100) NOT NULL UNIQUE, "year" varchar(100) NOT NULL);
CREATE INDEX "qwe_student_9603a224" ON "qwe_student" ("branch");
CREATE INDEX "qwe_student_name_f12973df_like" ON "qwe_student" ("name" varchar_pattern_ops);
CREATE INDEX "qwe_student_branch_21d799ac_like" ON "qwe_student" ("branch" varchar_pattern_ops);
CREATE INDEX "qwe_student_college_5063f3ca_like" ON "qwe_student" ("college" varchar_pattern_ops);
COMMIT;
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment