ALTER TABLE fields ADD CONSTRAINT fields_pk PRIMARY KEY ( id );

ALTER TABLE fields ADD CONSTRAINT fields_table_name UNIQUE ( table_id,
                                                             name );