An open-source, faster Devin alternative
TypeScript
migration(026): sandbox_tags table
Igor Zalutskid6d070cb17b3
diff --git a/internal/db/migrations/026_sandbox_tags.down.sql b/internal/db/migrations/026_sandbox_tags.down.sqlnew file mode 100644index 00000000..5b49dcf6--- /dev/null+++ b/internal/db/migrations/026_sandbox_tags.down.sql@@ -0,0 +1 @@+DROP TABLE IF EXISTS sandbox_tags;diff --git a/internal/db/migrations/026_sandbox_tags.up.sql b/internal/db/migrations/026_sandbox_tags.up.sqlnew file mode 100644index 00000000..bde879f7--- /dev/null+++ b/internal/db/migrations/026_sandbox_tags.up.sql@@ -0,0 +1,16 @@+-- Sandbox tags — per-sandbox customer-defined groupings (team, env,+-- customer, …) used to attribute usage without touching the Stripe+-- pricing path. Row-per-tag so grouping SQL is a single join and+-- per-sandbox tag-count limits are trivial. org_id is denormalized+-- so GET /tags can filter on (org_id, key) without a join.+CREATE TABLE IF NOT EXISTS sandbox_tags (+ org_id UUID NOT NULL,+ sandbox_id TEXT NOT NULL,+ key TEXT NOT NULL,+ value TEXT NOT NULL,+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ PRIMARY KEY (sandbox_id, key)+);++CREATE INDEX IF NOT EXISTS idx_sandbox_tags_org_key_value+ ON sandbox_tags (org_id, key, value);diff --git a/internal/db/store.go b/internal/db/store.goindex 3050a4c7..5b160e0e 100644--- a/internal/db/store.go+++ b/internal/db/store.go@@ -119,6 +119,7 @@ func (s *Store) Migrate(ctx context.Context) error {{26, "migrations/023_free_credits_remaining_cents.up.sql"},{27, "migrations/024_patch_error_tracking.up.sql"},{28, "migrations/025_sandbox_golden_version.up.sql"},+ {29, "migrations/026_sandbox_tags.up.sql"},}for _, m := range migrations {