mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-16 18:21:28 +08:00

* fix: support multitenancy in org * fix: register and login working now * fix: changes to migration * fix: migrations run both on sqlite and postgres * fix: remove user flags from fe and be * fix: remove ingestion keys from update * fix: multitenancy support for apdex settings * fix: render ts for users correctly * fix: fix migration to run for new tenants * fix: clean up migrations * fix: address comments * Update pkg/sqlmigration/013_update_organization.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: fix build * fix: force invites with org id * Update pkg/query-service/auth/auth.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: address comments * fix: address comments * fix: provier with their own dialect * fix: update dialects * fix: remove unwanted change * Update pkg/query-service/app/http_handler.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: different files for types --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
75 lines
2.2 KiB
Go
75 lines
2.2 KiB
Go
package sqlmigration
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/uptrace/bun"
|
|
"github.com/uptrace/bun/migrate"
|
|
"go.signoz.io/signoz/pkg/factory"
|
|
)
|
|
|
|
type addPats struct{}
|
|
|
|
func NewAddPatsFactory() factory.ProviderFactory[SQLMigration, Config] {
|
|
return factory.NewProviderFactory(factory.MustNewName("add_pats"), newAddPats)
|
|
}
|
|
|
|
func newAddPats(_ context.Context, _ factory.ProviderSettings, _ Config) (SQLMigration, error) {
|
|
return &addPats{}, nil
|
|
}
|
|
|
|
func (migration *addPats) Register(migrations *migrate.Migrations) error {
|
|
if err := migrations.Register(migration.Up, migration.Down); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (migration *addPats) Up(ctx context.Context, db *bun.DB) error {
|
|
if _, err := db.NewCreateTable().
|
|
Model(&struct {
|
|
bun.BaseModel `bun:"table:org_domains"`
|
|
|
|
ID string `bun:"id,pk,type:text"`
|
|
OrgID string `bun:"org_id,type:text,notnull"`
|
|
Name string `bun:"name,type:varchar(50),notnull,unique"`
|
|
CreatedAt int `bun:"created_at,notnull"`
|
|
UpdatedAt int `bun:"updated_at"`
|
|
Data string `bun:"data,type:text,notnull"`
|
|
}{}).
|
|
ForeignKey(`("org_id") REFERENCES "organizations" ("id")`).
|
|
IfNotExists().
|
|
Exec(ctx); err != nil {
|
|
return err
|
|
}
|
|
|
|
if _, err := db.NewCreateTable().
|
|
Model(&struct {
|
|
bun.BaseModel `bun:"table:personal_access_tokens"`
|
|
|
|
ID int `bun:"id,pk,autoincrement"`
|
|
Role string `bun:"role,type:text,notnull,default:'ADMIN'"`
|
|
UserID string `bun:"user_id,type:text,notnull"`
|
|
Token string `bun:"token,type:text,notnull,unique"`
|
|
Name string `bun:"name,type:text,notnull"`
|
|
CreatedAt int `bun:"created_at,notnull,default:0"`
|
|
ExpiresAt int `bun:"expires_at,notnull,default:0"`
|
|
UpdatedAt int `bun:"updated_at,notnull,default:0"`
|
|
LastUsed int `bun:"last_used,notnull,default:0"`
|
|
Revoked bool `bun:"revoked,notnull,default:false"`
|
|
UpdatedByUserID string `bun:"updated_by_user_id,type:text,notnull,default:''"`
|
|
}{}).
|
|
ForeignKey(`("user_id") REFERENCES "users" ("id")`).
|
|
IfNotExists().
|
|
Exec(ctx); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (migration *addPats) Down(ctx context.Context, db *bun.DB) error {
|
|
return nil
|
|
}
|