Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
2535fbf4
Verified
Commit
2535fbf4
authored
4 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
fix: replace contraints created on initial migration
parent
2e0bedae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
store/migrations.go
+39
-7
39 additions, 7 deletions
store/migrations.go
with
39 additions
and
7 deletions
store/migrations.go
+
39
−
7
View file @
2535fbf4
...
...
@@ -316,13 +316,45 @@ var (
)
func
initialMigration
(
tx
*
gorm
.
DB
)
(
err
error
)
{
return
tx
.
AutoMigrate
(
&
Show
{},
&
File
{},
&
ImportLog
{},
&
Playlist
{},
&
PlaylistEntry
{},
)
if
err
=
tx
.
AutoMigrate
(
&
Show
{},
&
File
{},
&
ImportLog
{},
&
Playlist
{},
&
PlaylistEntry
{});
err
!=
nil
{
return
err
}
// replace the constraints created
if
err
=
tx
.
Exec
(
"ALTER TABLE files DROP CONSTRAINT fk_files_show"
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE files ADD CONSTRAINT fk_files_show FOREIGN KEY (show_id) REFERENCES shows(id) ON UPDATE CASCADE ON DELETE CASCADE"
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE import_logs DROP CONSTRAINT fk_import_logs_file"
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE import_logs ADD CONSTRAINT fk_import_logs_file FOREIGN KEY (file_id) REFERENCES files(id) ON UPDATE CASCADE ON DELETE CASCADE "
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE playlists DROP CONSTRAINT fk_playlists_show"
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE playlists ADD CONSTRAINT fk_playlists_show FOREIGN KEY (show_id) REFERENCES shows(id) ON UPDATE CASCADE ON DELETE CASCADE "
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE playlist_entries DROP CONSTRAINT fk_playlist_entries_file"
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE playlist_entries ADD CONSTRAINT fk_playlist_entries_file FOREIGN KEY (file_id) REFERENCES files(id) ON UPDATE CASCADE ON DELETE RESTRICT "
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE playlist_entries DROP CONSTRAINT fk_playlists_entries"
)
.
Error
;
err
!=
nil
{
return
err
}
if
err
=
tx
.
Exec
(
"ALTER TABLE playlist_entries ADD CONSTRAINT fk_playlists_entries FOREIGN KEY (playlist_id) REFERENCES playlists(id) ON UPDATE CASCADE ON DELETE CASCADE "
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
(
st
*
Store
)
initDBModel
(
cfg
DBConfig
)
(
err
error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment