[DB] Fix Doctrine errors due to lack of column uniqueness

So, Doctrine doesn't like that `GSActorTag.tag` is not unique, even
though composite key `[tagger, tag]` is. `tag` can't unique, but
doctrine doesn't understand this. This seems like a Doctrine bug that
should be investigated. For now we'll just not mark it as a foreign
key
This commit is contained in:
Hugo Sales 2021-03-25 22:20:28 +00:00
parent 2e490756b9
commit 2174f288d1
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 11 additions and 6 deletions

View File

@ -296,7 +296,10 @@ class GSActor extends Entity
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'indexes' => [ 'unique keys' => [
'gsactor_nickname_uniq' => ['nickname'],
],
'indexes' => [
'gsactor_nickname_idx' => ['nickname'], 'gsactor_nickname_idx' => ['nickname'],
], ],
'fulltext indexes' => [ 'fulltext indexes' => [

View File

@ -132,8 +132,9 @@ class GSActorCircle extends Entity
'name' => 'gsactor_circle', 'name' => 'gsactor_circle',
'description' => 'a gsactor can have lists of gsactors, to separate their timeline', 'description' => 'a gsactor can have lists of gsactors, to separate their timeline',
'fields' => [ 'fields' => [
'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'gsactor_list_tagger_fkey', 'not null' => true, 'description' => 'user making the tag'], 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'gsactor_list_tagger_fkey', 'not null' => true, 'description' => 'user making the tag'],
'tag' => ['type' => 'varchar', 'foreign key' => true, 'length' => 64, 'target' => 'GSActorTag.tag', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'gsactor tag'], // Join with GSActorTag 'tag' => ['type' => 'varchar', 'length' => 64 //, 'foreign key' => true, 'target' => 'GSActorTag.tag', 'multiplicity' => 'many to one' // so, Doctrine doesn't like that the target is not unique, even though the pair is
, 'not null' => true, 'description' => 'gsactor tag', ], // Join with GSActorTag
'description' => ['type' => 'text', 'description' => 'description of the people tag'], 'description' => ['type' => 'text', 'description' => 'description of the people tag'],
'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'], 'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],

View File

@ -95,10 +95,11 @@ class GSActorTagFollow extends Entity
return [ return [
'name' => 'gsactor_tag_follow', 'name' => 'gsactor_tag_follow',
'fields' => [ 'fields' => [
'gsactor_tag' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActorTag.tag', 'multiplicity' => 'one to one', 'name' => 'gsactor_tag_follow_gsactor_tag_fkey', 'not null' => true, 'description' => 'foreign key to gsactor_tag'],
'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'gsactor_tag_follow_gsactor_id_fkey', 'not null' => true, 'description' => 'foreign key to gsactor table'], 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'gsactor_tag_follow_gsactor_id_fkey', 'not null' => true, 'description' => 'foreign key to gsactor table'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'gsactor_tag' => ['type' => 'int', // 'foreign key' => true, 'target' => 'GSActorTag.tag', 'multiplicity' => 'one to one', // tag can't unique, but doctrine doesn't understand this
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], 'name' => 'gsactor_tag_follow_gsactor_tag_fkey', 'not null' => true, 'description' => 'foreign key to gsactor_tag', ],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['gsactor_tag_id', 'gsactor_id'], 'primary key' => ['gsactor_tag_id', 'gsactor_id'],
'indexes' => [ 'indexes' => [