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
33f090f8
Commit
33f090f8
authored
5 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
added description field to playlist
parent
32c7d9b2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
store/migrations.go
+20
-1
20 additions, 1 deletion
store/migrations.go
store/types.go
+7
-6
7 additions, 6 deletions
store/types.go
with
27 additions
and
7 deletions
store/migrations.go
+
20
−
1
View file @
33f090f8
...
@@ -26,6 +26,7 @@ package store
...
@@ -26,6 +26,7 @@ package store
import
(
import
(
"errors"
"errors"
"time"
"github.com/jinzhu/gorm"
"github.com/jinzhu/gorm"
"gopkg.in/gormigrate.v1"
"gopkg.in/gormigrate.v1"
...
@@ -72,6 +73,24 @@ func (st *Store) initDBModel() (err error) {
...
@@ -72,6 +73,24 @@ func (st *Store) initDBModel() (err error) {
Migrate
:
func
(
tx
*
gorm
.
DB
)
error
{
return
nil
},
Migrate
:
func
(
tx
*
gorm
.
DB
)
error
{
return
nil
},
Rollback
:
func
(
tx
*
gorm
.
DB
)
error
{
return
nil
},
Rollback
:
func
(
tx
*
gorm
.
DB
)
error
{
return
nil
},
},
},
{
ID
:
"201905160033"
,
Migrate
:
func
(
tx
*
gorm
.
DB
)
error
{
type
Playlist
struct
{
ID
uint64
`json:"id" gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"created"`
UpdatedAt
time
.
Time
`json:"updated"`
Description
string
`json:"description"`
ShowName
string
`json:"show" gorm:"not null;index"`
Show
Show
`json:"-" gorm:"association_foreignkey:Name"`
Entries
[]
PlaylistEntry
`json:"entries,omitempty"`
}
return
tx
.
AutoMigrate
(
&
Playlist
{})
.
Error
},
Rollback
:
func
(
tx
*
gorm
.
DB
)
error
{
return
tx
.
Table
(
"playlists"
)
.
DropColumn
(
"description"
)
.
Error
},
},
})
})
m
.
InitSchema
(
initialMigration
)
m
.
InitSchema
(
initialMigration
)
...
@@ -79,7 +98,7 @@ func (st *Store) initDBModel() (err error) {
...
@@ -79,7 +98,7 @@ func (st *Store) initDBModel() (err error) {
return
errors
.
New
(
"running database migrations failed: "
+
err
.
Error
())
return
errors
.
New
(
"running database migrations failed: "
+
err
.
Error
())
}
}
if
err
=
st
.
db
.
Table
(
migrationsTn
)
.
Select
(
"id"
)
.
Order
(
"id"
)
.
Limit
(
1
)
.
Row
()
.
Scan
(
&
st
.
revision
);
err
!=
nil
{
if
err
=
st
.
db
.
Table
(
migrationsTn
)
.
Select
(
"id"
)
.
Order
(
"id
DESC
"
)
.
Limit
(
1
)
.
Row
()
.
Scan
(
&
st
.
revision
);
err
!=
nil
{
return
errors
.
New
(
"fetching current database revision failed: "
+
err
.
Error
())
return
errors
.
New
(
"fetching current database revision failed: "
+
err
.
Error
())
}
}
return
return
...
...
This diff is collapsed.
Click to expand it.
store/types.go
+
7
−
6
View file @
33f090f8
...
@@ -191,12 +191,13 @@ type PlaylistEntry struct {
...
@@ -191,12 +191,13 @@ type PlaylistEntry struct {
}
}
type
Playlist
struct
{
type
Playlist
struct
{
ID
uint64
`json:"id" gorm:"primary_key"`
ID
uint64
`json:"id" gorm:"primary_key"`
CreatedAt
time
.
Time
`json:"created"`
CreatedAt
time
.
Time
`json:"created"`
UpdatedAt
time
.
Time
`json:"updated"`
UpdatedAt
time
.
Time
`json:"updated"`
ShowName
string
`json:"show" gorm:"not null;index"`
Description
string
`json:"description"`
Show
Show
`json:"-" gorm:"association_foreignkey:Name"`
ShowName
string
`json:"show" gorm:"not null;index"`
Entries
[]
PlaylistEntry
`json:"entries,omitempty"`
Show
Show
`json:"-" gorm:"association_foreignkey:Name"`
Entries
[]
PlaylistEntry
`json:"entries,omitempty"`
}
}
type
Playlists
[]
Playlist
type
Playlists
[]
Playlist
...
...
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