diff options
author | 2021-03-08 22:37:56 +0100 | |
---|---|---|
committer | 2021-03-08 22:37:56 +0100 | |
commit | 338af00e7bb2410f50b514f37f49418b293c0e29 (patch) | |
tree | 72f9b7ad13ff88c64e05e8d58f1411e2be45e79c /internal/db/postgres.go | |
parent | tiny experiments (diff) | |
download | gotosocial-338af00e7bb2410f50b514f37f49418b293c0e29.tar.xz |
add note struct
Diffstat (limited to 'internal/db/postgres.go')
-rw-r--r-- | internal/db/postgres.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/db/postgres.go b/internal/db/postgres.go index a5c4024de..a66b1364a 100644 --- a/internal/db/postgres.go +++ b/internal/db/postgres.go @@ -103,8 +103,22 @@ func newPostgresService(ctx context.Context, c *config.Config, log *logrus.Entry acc := model.StubAccount() if _, err := conn.Model(acc).Returning("id").Insert(); err != nil { cancel() - return nil, errors.New("db insert error") + return nil, fmt.Errorf("db insert error: %s", err) } + log.Infof("created account with id %s", acc.ID) + + note := &model.Note{ + Visibility: &model.Visibility{ + Local: true, + }, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + if _, err := conn.Model(note).Returning("id").Insert(); err != nil { + cancel() + return nil, fmt.Errorf("db insert error: %s", err) + } + log.Infof("created note with id %s", note.ID) // we can confidently return this useable postgres service now return &postgresService{ @@ -300,6 +314,7 @@ func (ps *postgresService) Stop(ctx context.Context) error { func (ps *postgresService) CreateSchema(ctx context.Context) error { models := []interface{}{ (*model.Account)(nil), + (*model.Note)(nil), } ps.log.Info("creating db schema") |