chore: update database migrator

This commit is contained in:
Steven
2024-01-06 16:55:13 +08:00
parent fd8333eeda
commit d67eaaaee2
21 changed files with 71 additions and 385 deletions

View File

@@ -25,7 +25,7 @@ func (d *DB) CreateWebhook(ctx context.Context, create *storepb.Webhook) (*store
}
create.Id = int32(id)
return create, nil
return d.GetWebhook(ctx, &store.FindWebhook{ID: &create.Id})
}
func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*storepb.Webhook, error) {
@@ -37,7 +37,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
where, args = append(where, "`creator_id` = ?"), append(args, *find.CreatorID)
}
rows, err := d.db.QueryContext(ctx, "SELECT `id`, `created_ts`, `updated_ts`, `row_status`, `creator_id`, `name`, `url` FROM `webhook` WHERE "+strings.Join(where, " AND ")+" ORDER BY `id` DESC",
rows, err := d.db.QueryContext(ctx, "SELECT `id`, UNIX_TIMESTAMP(`created_ts`), UNIX_TIMESTAMP(`updated_ts`), `row_status`, `creator_id`, `name`, `url` FROM `webhook` WHERE "+strings.Join(where, " AND ")+" ORDER BY `id` DESC",
args...,
)
if err != nil {