开发者

Alter Table Set unique error on postgres

开发者 https://www.devze.com 2023-01-10 04:11 出处:网络
I am using Postgres as DBMS and Django. My model that defines the table is: class TtnetModem(models.Model):

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

精彩评论

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

关注公众号