mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-13 06:07:29 -06:00
create tables on startup
This commit is contained in:
parent
f8a3dc1da7
commit
e65a31e501
1 changed files with 29 additions and 0 deletions
|
|
@ -40,6 +40,7 @@ import (
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/federation"
|
"github.com/superseriousbusiness/gotosocial/internal/federation"
|
||||||
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/message"
|
"github.com/superseriousbusiness/gotosocial/internal/message"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||||
|
|
@ -49,6 +50,28 @@ import (
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var models []interface{} = []interface{}{
|
||||||
|
>smodel.Account{},
|
||||||
|
>smodel.Application{},
|
||||||
|
>smodel.Block{},
|
||||||
|
>smodel.DomainBlock{},
|
||||||
|
>smodel.EmailDomainBlock{},
|
||||||
|
>smodel.Follow{},
|
||||||
|
>smodel.FollowRequest{},
|
||||||
|
>smodel.MediaAttachment{},
|
||||||
|
>smodel.Mention{},
|
||||||
|
>smodel.Status{},
|
||||||
|
>smodel.StatusFave{},
|
||||||
|
>smodel.StatusBookmark{},
|
||||||
|
>smodel.StatusMute{},
|
||||||
|
>smodel.StatusPin{},
|
||||||
|
>smodel.Tag{},
|
||||||
|
>smodel.User{},
|
||||||
|
>smodel.Emoji{},
|
||||||
|
&oauth.Token{},
|
||||||
|
&oauth.Client{},
|
||||||
|
}
|
||||||
|
|
||||||
// Run creates and starts a gotosocial server
|
// Run creates and starts a gotosocial server
|
||||||
var Run action.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error {
|
var Run action.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error {
|
||||||
dbService, err := db.NewPostgresService(ctx, c, log)
|
dbService, err := db.NewPostgresService(ctx, c, log)
|
||||||
|
|
@ -109,6 +132,12 @@ var Run action.GTSAction = func(ctx context.Context, c *config.Config, log *logr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, m := range models {
|
||||||
|
if err := dbService.CreateTable(m); err != nil {
|
||||||
|
return fmt.Errorf("table creation error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := dbService.CreateInstanceAccount(); err != nil {
|
if err := dbService.CreateInstanceAccount(); err != nil {
|
||||||
return fmt.Errorf("error creating instance account: %s", err)
|
return fmt.Errorf("error creating instance account: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue