Revision d817962e
Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt
SL/DB/MetaSetup/Price.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
__PACKAGE__->meta->columns( |
12 | 12 |
id => { type => 'serial', not_null => 1 }, |
13 |
parts_id => { type => 'integer' }, |
|
13 |
parts_id => { type => 'integer', not_null => 1 },
|
|
14 | 14 |
price => { type => 'numeric', precision => 15, scale => 5 }, |
15 |
pricegroup_id => { type => 'integer' }, |
|
15 |
pricegroup_id => { type => 'integer', not_null => 1 },
|
|
16 | 16 |
); |
17 | 17 |
|
18 | 18 |
__PACKAGE__->meta->primary_key_columns([ 'id' ]); |
19 | 19 |
|
20 |
__PACKAGE__->meta->unique_keys([ 'parts_id', 'pricegroup_id' ]); |
|
21 |
|
|
20 | 22 |
__PACKAGE__->meta->foreign_keys( |
21 | 23 |
parts => { |
22 | 24 |
class => 'SL::DB::Part', |
sql/Pg-upgrade2/prices_unique.sql | ||
---|---|---|
1 |
-- @tag: prices_unique |
|
2 |
-- @description: DB-Constraint - nur ein Preis pro Artikel pro Preisgruppe |
|
3 |
-- @depends: release_3_4_1 |
|
4 |
|
|
5 |
-- it would be easier to just have a composite primary key on parts_id and |
|
6 |
-- pricegroup_id, but that would need some code refactoring |
|
7 |
ALTER TABLE prices ADD CONSTRAINT parts_id_pricegroup_id_unique UNIQUE (parts_id, pricegroup_id); |
|
8 |
ALTER TABLE prices ALTER COLUMN parts_id SET NOT NULL; |
|
9 |
ALTER TABLE prices ALTER COLUMN pricegroup_id SET NOT NULL; |
Auch abrufbar als: Unified diff
Tabelle prices - not null und unique auf parts_id und partsgroup_id