i think this example shows it all: after changing my model, i use manage.py sql
to rebuild the schema, and then manage.py syncdb
to sync it with postgres. but psql
does not reflect the changes?! watch in particular the NULL
status of attributes like CTYPE
:
$ python manage.py sql showCrime
BEGIN;
CREATE TABLE "showCrime_oakcrime" (
"idx" integer NOT NULL PRIMARY KEY,
"opd_rd" varchar(10) NOT NULL,
"oidx" integer NOT NULL,
"cdate" date NOT NULL,
"ctime" time NOT NULL,
"ctype" varchar(50),
"desc" varchar(80),
"beat" varchar(5),
"addr" varchar(80),
"lat" double precision,
"long" double precision,
"ucr" varchar(5),
"statute" varchar(50),
"crimeCat" varchar(50)
)
;
COMMIT;
$ python manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
$ psql -U USERNAME djangodb
djangodb=> d "showCrime_oakcrime"
Table "public.showCrime_oakcrime"
Column | Type | Modifiers
----------+------------------------+-----------
idx | integer | not null
opd_rd | character varying(10) | not null
oidx | integer | not null
cdate | date | not null
ctime | time without time zone | not null
ctype | character varying(50) | not null
desc | character varying(80) | not null
beat | character varying(5) | not null
addr | character varying(80) |
lat | double precision |
long | double precision |
ucr | character varying(5) |
statute | character varying(50) |
crimeCat | character varying(50) |
Indexes:
"showCrime_oakcrime_pkey1" PRIMARY KEY, btree (idx)
at one point CTYPE
and the others did have NOT NULL
qualifiers (because i'd mis-specified blank,null
values in my django model) but they are staying as they were; there seems to be some database state maintained somewhere?
asked
21 May '13, 17:02
rikEA
23●2●6
accept rate:
0%