@@ -48,7 +48,7 @@ func (m *MariaDB) InitializeSchema() error {
48
48
49
49
CONSTRAINT pk_source PRIMARY KEY (id),
50
50
51
- UNIQUE unique_source_idx (name, auth_token)
51
+ UNIQUE unique_source (name, auth_token)
52
52
)` )
53
53
if err != nil {
54
54
return fmt .Errorf ("Unable to create sources table: %v" , err )
@@ -63,7 +63,8 @@ func (m *MariaDB) InitializeSchema() error {
63
63
64
64
CONSTRAINT pk_asset PRIMARY KEY (id),
65
65
66
- UNIQUE unique_asset_idx (type, value),
66
+ UNIQUE unique_asset (type, value),
67
+
67
68
INDEX value_idx (value),
68
69
INDEX type_idx (type))` )
69
70
if err != nil {
@@ -81,6 +82,8 @@ func (m *MariaDB) InitializeSchema() error {
81
82
CONSTRAINT fk_from FOREIGN KEY (from_id) REFERENCES assets (id),
82
83
CONSTRAINT fk_to FOREIGN KEY (to_id) REFERENCES assets (id),
83
84
85
+ UNIQUE unique_relation (from_id, to_id, type),
86
+
84
87
INDEX full_relation_type_from_to_idx (type, from_id, to_id),
85
88
INDEX full_relation_type_to_from_idx (type, to_id, from_id),
86
89
INDEX full_relation_from_type_to_idx (from_id, type, to_id),
@@ -97,6 +100,8 @@ func (m *MariaDB) InitializeSchema() error {
97
100
source_id INT NOT NULL,
98
101
relation_id BIGINT UNSIGNED NOT NULL,
99
102
update_time TIMESTAMP,
103
+
104
+ UNIQUE unique_relation_by_source (source_id, relation_id),
100
105
101
106
CONSTRAINT pk_relations_by_source PRIMARY KEY (id),
102
107
CONSTRAINT fk_relations_by_source_source_id FOREIGN KEY (source_id) REFERENCES sources (id) ON DELETE CASCADE,
@@ -113,6 +118,8 @@ func (m *MariaDB) InitializeSchema() error {
113
118
source_id INT NOT NULL,
114
119
asset_id BIGINT UNSIGNED NOT NULL,
115
120
update_time TIMESTAMP,
121
+
122
+ UNIQUE unique_asset_by_source (source_id, asset_id),
116
123
117
124
CONSTRAINT pk_assets_by_source PRIMARY KEY (id),
118
125
CONSTRAINT fk_asset_by_source_source_id FOREIGN KEY (source_id) REFERENCES sources (id) ON DELETE CASCADE,
0 commit comments