﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
4070	unique_for_date and friends should create database indexes where possible	sam@…	nobody	"Currently the field options unique_for_date, etc. do not create database indexes. I think this should be changed where the database backend supports this.

For example, with PostgreSQL:

{{{
db=> CREATE TABLE FOO (date timestamp with time zone, slug text);
db=> CREATE UNIQUE INDEX foo_unqiue_date ON foo (date_trunc ('day', date AT TIME ZONE 'UTC'), slug);
db=> INSERT INTO FOO VALUES (now(), 'slug1');
INSERT 0 1
db=> INSERT INTO FOO VALUES (now(), 'slug2');
INSERT 0 1
db=> INSERT INTO FOO VALUES (now(), 'slug1');
ERROR:  duplicate key violates unique constraint ""foo_unique_date""
}}}

The date_trunc function can be used to truncate the timestamp data to any desired precision, so it can be used for the other unqiue_for attributes."	New feature	closed	Database layer (models, ORM)	dev	Normal	wontfix			Accepted	0	0	0	0	0	0
