Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions internal/store/postgres/person_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (personRepository PersonRepository) canonicalizePersonReferences(legacyPers
return errorValue
}
}
return personRepository.canonicalizePersonCircles(legacyPersonID, personID)
return nil
}

func canonicalPersonReferenceUpdateStatements() []canonicalPersonReferenceUpdate {
Expand All @@ -145,20 +145,3 @@ func (personRepository PersonRepository) hasTable(tableName string) (bool, error
errorValue := row.Scan(&hasTable)
return hasTable, errorValue
}

func (personRepository PersonRepository) canonicalizePersonCircles(legacyPersonID string, personID string) error {
_, errorValue := personRepository.database.SQL.ExecContext(context.Background(), `
INSERT INTO person_circle (person_circle_id, person_id, circle_id, source, created_at, updated_at)
SELECT $2 || ':' || circle_id, $2, circle_id, source, created_at, updated_at
FROM person_circle
WHERE person_id = $1
ON CONFLICT (person_id, circle_id) DO UPDATE SET
source = EXCLUDED.source,
updated_at = EXCLUDED.updated_at`, legacyPersonID, personID)
if errorValue != nil {
return errorValue
}
_, errorValue = personRepository.database.SQL.ExecContext(context.Background(), `
DELETE FROM person_circle WHERE person_id = $1`, legacyPersonID)
return errorValue
}
4 changes: 4 additions & 0 deletions migrations/030_drop_the_circle_tables_nobody_reads.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DROP TABLE IF EXISTS mattermost_circle_link;
DROP TABLE IF EXISTS person_circle;
DROP TABLE IF EXISTS circle;
DROP TABLE IF EXISTS resource_access_rule;
4 changes: 2 additions & 2 deletions tests/integration/migrations_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func TestMigrationsApplyList(t *testing.T) {
if errorValue != nil {
t.Fatalf("expected migrations to load: %v", errorValue)
}
if len(migrationPaths) != 29 {
t.Fatalf("expected 29 migration files, got %d", len(migrationPaths))
if len(migrationPaths) != 30 {
t.Fatalf("expected 30 migration files, got %d", len(migrationPaths))
}
}

Expand Down
Loading