Closed danriti closed 11 years ago
We should also put a unique constraint on the [code]name[/code] column
http://peewee.readthedocs.org/en/latest/peewee/api.html#fields-api
Looks like it's as easy to setup on the name
field, however it might only do this upon table creation:
unique (bool) – whether to create a unique index for this column when creating the table
We can change the model on the peewee side so the name field is unique. And manually alter the table on the DB side.
Perfect...sounds great!
So just a heads up, did some poking around to see if peewee supported migrations, and unfortunately it looks like the answer is no:
http://peewee.readthedocs.org/en/latest/peewee/cookbook.html#schema-migrations
However, there are plenty of methods available to the Database
class that would let us write stand alone Python scripts that can act as migrations, such as:
http://peewee.readthedocs.org/en/latest/peewee/api.html#Database.create_index
It's a bit overkill for this issue, however it might be a cool idea/side project to work on in the future?
Table update. Use this query in the future in case dups end up in the table.
update dream set name = replace(name, '%20', ' ');
Also, table altered -- unique key created on the dream table
alter table dream add unique key (name);
Based on our previous conversation:
Also note that rows
24
and35
will be duplicates!