开发者

Alter Table Set unique error on postgres

I am using Postgres as DBMS and Django.

My model that defines the table is:

class TtnetModem(models.Model):
    ttnetModemSerino=models.CharField(_(u"Ser开发者_如何学Ci No"), max_length=20, default='', null=True, blank=True)

I change field definition...

ttnetModemSerino=models.CharField(_(u"Seri No"), max_length=20, unique= True)

on postgres, i execute :

ALTER TABLE bayiislemleri_ttnetmodem ADD CONSTRAINT ttnetModemSerino_key UNIQUE(ttnetModemSerino);

bayiislemleri is my application name and ttnetmodem is my model name... But i get floolwing error:

ERROR: column "ttnetmodemserino" named in key does not exist

What am i doing wrong?


ttnetmodemserino is in lower case, it looks like ttnetModemSerino has some upper case characters. Make sure your piece of SQL uses double quotes for the objects:

ALTER TABLE bayiislemleri_ttnetmodem ADD CONSTRAINT ttnetModemSerino_key UNIQUE("ttnetModemSerino");

I have no idea how to do it in Django, can't help you there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜