فهرست منبع

storing porter app revision on create stack

Stefan McShane 3 سال پیش
والد
کامیت
3987d39dcd

+ 8 - 3
Taskfile.yaml

@@ -5,10 +5,10 @@ tasks:
     desc: Move the current branch to production
     cmds:
     - cmd: git tag -d production
-      ignore_error: false
+      ignore_error: true
       silent: true
     - cmd: git push origin :production
-      ignore_error: false
+      ignore_error: true
       silent: true
     - cmd: git tag production
       ignore_error: false
@@ -17,4 +17,9 @@ tasks:
       ignore_error: false
       silent: true
  
-
+  generate:
+    desc: Generate SQL migrations
+    cmds:
+    - cmd: go generate ./database/...
+      ignore_error: false
+      silent: true

+ 11 - 0
api/server/handlers/stacks/create.go

@@ -11,6 +11,7 @@ import (
 	"github.com/porter-dev/porter/api/server/shared/apierrors"
 	"github.com/porter-dev/porter/api/server/shared/config"
 	"github.com/porter-dev/porter/api/types"
+	"github.com/porter-dev/porter/database/generated/queries"
 	"github.com/porter-dev/porter/internal/helm"
 	"github.com/porter-dev/porter/internal/models"
 )
@@ -41,6 +42,16 @@ func (c *CreateStackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	porterAppRevision := queries.CreatePorterAppRevisionParams{
+		ProjectID:      int64(cluster.ProjectID),
+		Base64Contract: request.PorterYAMLBase64,
+	}
+	_, err := c.Config().Database.CreatePorterAppRevision(ctx, porterAppRevision)
+	if err != nil {
+		c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError, "error creating porter app revision", err.Error()))
+		return
+	}
+
 	stackName := request.StackName
 	namespace := fmt.Sprintf("porter-stack-%s", stackName)
 

+ 4 - 0
api/server/shared/config/config.go

@@ -6,6 +6,7 @@ import (
 	"github.com/porter-dev/porter/api/server/shared/apierrors/alerter"
 	"github.com/porter-dev/porter/api/server/shared/config/env"
 	"github.com/porter-dev/porter/api/server/shared/websocket"
+	"github.com/porter-dev/porter/database/generated/queries"
 	"github.com/porter-dev/porter/internal/analytics"
 	"github.com/porter-dev/porter/internal/auth/token"
 	"github.com/porter-dev/porter/internal/billing"
@@ -83,6 +84,9 @@ type Config struct {
 	// DB is the gorm DB instance
 	DB *gorm.DB
 
+	// Database is the SQLC generated DB instance, which implements database/sql package
+	Database *queries.Queries
+
 	// AnalyticsClient if Segment analytics reporting is enabled on the API instance
 	AnalyticsClient analytics.AnalyticsSegmentClient
 

+ 7 - 0
api/server/shared/config/loader/loader.go

@@ -17,6 +17,7 @@ import (
 	"github.com/porter-dev/porter/api/server/shared/config/env"
 	"github.com/porter-dev/porter/api/server/shared/config/envloader"
 	"github.com/porter-dev/porter/api/server/shared/websocket"
+	"github.com/porter-dev/porter/database/generated/queries"
 	"github.com/porter-dev/porter/internal/adapter"
 	"github.com/porter-dev/porter/internal/analytics"
 	"github.com/porter-dev/porter/internal/auth/sessionstore"
@@ -83,6 +84,12 @@ func (e *EnvConfigLoader) LoadConfig() (res *config.Config, err error) {
 	res.Logger.Info().Msg("Loaded MetadataFromConf")
 	res.DB = InstanceDB
 
+	sqlDB, err := res.DB.DB()
+	if err != nil {
+		return nil, fmt.Errorf("could not get sqlc db: %s", err.Error())
+	}
+	res.Database = queries.New(sqlDB)
+
 	// res.Logger.Info().Msg("Starting gorm automigrate")
 	// err = gorm.AutoMigrate(InstanceDB, sc.Debug)
 	//

+ 4 - 0
database/generate.go

@@ -0,0 +1,4 @@
+package database
+
+//go:generate sqlc generate -f sqlc.yaml
+//go:generate atlas migrate diff --dir file://migrations --to file://schema.sql --dev-url "postgresql://porter:porter@localhost:5432/atlas?sslmode=disable" --format "{{ sql . ' ' }}"

+ 31 - 0
database/generated/queries/db.go

@@ -0,0 +1,31 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.18.0
+
+package queries
+
+import (
+	"context"
+	"database/sql"
+)
+
+type DBTX interface {
+	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
+	PrepareContext(context.Context, string) (*sql.Stmt, error)
+	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
+	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
+}
+
+func New(db DBTX) *Queries {
+	return &Queries{db: db}
+}
+
+type Queries struct {
+	db DBTX
+}
+
+func (q *Queries) WithTx(tx *sql.Tx) *Queries {
+	return &Queries{
+		db: tx,
+	}
+}

+ 913 - 0
database/generated/queries/models.go

@@ -0,0 +1,913 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.18.0
+
+package queries
+
+import (
+	"database/sql"
+	"time"
+
+	"github.com/google/uuid"
+	"github.com/tabbed/pqtype"
+)
+
+type Allowlist struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	UserEmail string
+}
+
+type ApiContractRevision struct {
+	ID                uuid.UUID
+	CreatedAt         sql.NullTime
+	UpdatedAt         sql.NullTime
+	DeletedAt         sql.NullTime
+	Base64Contract    sql.NullString
+	ClusterID         sql.NullInt64
+	ProjectID         sql.NullInt64
+	Condition         sql.NullString
+	ConditionMetadata pqtype.NullRawMessage
+}
+
+type ApiToken struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	UniqueID        sql.NullString
+	ProjectID       sql.NullInt64
+	CreatedByUserID sql.NullInt64
+	Expiry          sql.NullTime
+	Revoked         sql.NullBool
+	PolicyUid       sql.NullString
+	PolicyName      sql.NullString
+	Name            sql.NullString
+	SecretKey       []byte
+}
+
+type AuthCode struct {
+	ID                int64
+	CreatedAt         sql.NullTime
+	UpdatedAt         sql.NullTime
+	DeletedAt         sql.NullTime
+	Token             sql.NullString
+	AuthorizationCode sql.NullString
+	Expiry            sql.NullTime
+}
+
+type AwsAssumeRoleChain struct {
+	ID         uuid.UUID
+	CreatedAt  sql.NullTime
+	UpdatedAt  sql.NullTime
+	DeletedAt  sql.NullTime
+	ProjectID  sql.NullInt64
+	SourceArn  sql.NullString
+	TargetArn  sql.NullString
+	ExternalID sql.NullString
+}
+
+type AwsIntegration struct {
+	ID                 int64
+	CreatedAt          sql.NullTime
+	UpdatedAt          sql.NullTime
+	DeletedAt          sql.NullTime
+	UserID             sql.NullInt64
+	ProjectID          sql.NullInt64
+	AwsArn             sql.NullString
+	AwsRegion          sql.NullString
+	AwsAssumeRoleArn   sql.NullString
+	AwsClusterID       []byte
+	AwsAccessKeyID     []byte
+	AwsSecretAccessKey []byte
+	AwsSessionToken    []byte
+}
+
+type AzureIntegration struct {
+	ID                     int64
+	CreatedAt              sql.NullTime
+	UpdatedAt              sql.NullTime
+	DeletedAt              sql.NullTime
+	UserID                 sql.NullInt64
+	ProjectID              sql.NullInt64
+	AzureClientID          sql.NullString
+	AzureSubscriptionID    sql.NullString
+	AzureTenantID          sql.NullString
+	AcrTokenName           sql.NullString
+	AcrResourceGroupName   sql.NullString
+	AcrName                sql.NullString
+	ServicePrincipalSecret []byte
+	AcrPassword1           []byte
+	AcrPassword2           []byte
+	AksPassword            []byte
+}
+
+type BasicIntegration struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	UserID    sql.NullInt64
+	ProjectID sql.NullInt64
+	Username  []byte
+	Password  []byte
+}
+
+type BuildConfig struct {
+	ID         int64
+	CreatedAt  sql.NullTime
+	UpdatedAt  sql.NullTime
+	DeletedAt  sql.NullTime
+	Name       sql.NullString
+	Builder    sql.NullString
+	Buildpacks sql.NullString
+	Config     []byte
+}
+
+type Cluster struct {
+	ID                                int64
+	CreatedAt                         sql.NullTime
+	UpdatedAt                         sql.NullTime
+	DeletedAt                         sql.NullTime
+	AuthMechanism                     sql.NullString
+	ProjectID                         sql.NullInt64
+	AgentIntegrationEnabled           sql.NullBool
+	Name                              sql.NullString
+	VanityName                        sql.NullString
+	Server                            sql.NullString
+	ClusterLocationOfOrigin           sql.NullString
+	TlsServerName                     sql.NullString
+	InsecureSkipTlsVerify             sql.NullBool
+	ProxyUrl                          sql.NullString
+	UserLocationOfOrigin              sql.NullString
+	UserImpersonate                   sql.NullString
+	UserImpersonateGroups             sql.NullString
+	InfraID                           sql.NullInt64
+	NotificationsDisabled             sql.NullBool
+	PreviewEnvsEnabled                sql.NullBool
+	AwsClusterID                      sql.NullString
+	Status                            sql.NullString
+	ProvisionedBy                     sql.NullString
+	CloudProvider                     sql.NullString
+	CloudProviderCredentialIdentifier sql.NullString
+	KubeIntegrationID                 sql.NullInt64
+	OIDCIntegrationID                 sql.NullInt64
+	GcpIntegrationID                  sql.NullInt64
+	AwsIntegrationID                  sql.NullInt64
+	DoIntegrationID                   sql.NullInt64
+	AzureIntegrationID                sql.NullInt64
+	TokenCacheID                      sql.NullInt64
+	CertificateAuthorityData          []byte
+	MonitorHelmReleases               sql.NullBool
+}
+
+type ClusterCandidate struct {
+	ID                int64
+	CreatedAt         sql.NullTime
+	UpdatedAt         sql.NullTime
+	DeletedAt         sql.NullTime
+	AuthMechanism     sql.NullString
+	ProjectID         sql.NullInt64
+	CreatedClusterID  sql.NullInt64
+	Name              sql.NullString
+	Server            sql.NullString
+	ContextName       sql.NullString
+	AwsClusterIDGuess []byte
+	Kubeconfig        []byte
+}
+
+type ClusterResolver struct {
+	ID                 int64
+	CreatedAt          sql.NullTime
+	UpdatedAt          sql.NullTime
+	DeletedAt          sql.NullTime
+	ClusterCandidateID sql.NullInt64
+	Name               sql.NullString
+	Resolved           sql.NullBool
+	Data               []byte
+}
+
+type ClusterTokenCach struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Expiry    sql.NullTime
+	Token     []byte
+	ClusterID sql.NullInt64
+}
+
+type CredentialsExchangeToken struct {
+	ID                int64
+	CreatedAt         sql.NullTime
+	UpdatedAt         sql.NullTime
+	DeletedAt         sql.NullTime
+	ProjectID         sql.NullInt64
+	Token             []byte
+	Expiry            sql.NullTime
+	DoCredentialID    sql.NullInt64
+	AwsCredentialID   sql.NullInt64
+	GcpCredentialID   sql.NullInt64
+	AzureCredentialID sql.NullInt64
+}
+
+type Database struct {
+	ID               int64
+	CreatedAt        sql.NullTime
+	UpdatedAt        sql.NullTime
+	DeletedAt        sql.NullTime
+	ProjectID        sql.NullInt64
+	ClusterID        sql.NullInt64
+	InfraID          sql.NullInt64
+	InstanceID       sql.NullString
+	InstanceEndpoint sql.NullString
+	InstanceName     sql.NullString
+	Status           sql.NullString
+}
+
+type DbMigration struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Version   sql.NullInt64
+}
+
+type Deployment struct {
+	ID             int64
+	CreatedAt      sql.NullTime
+	UpdatedAt      sql.NullTime
+	DeletedAt      sql.NullTime
+	EnvironmentID  sql.NullInt64
+	Namespace      sql.NullString
+	Status         sql.NullString
+	Subdomain      sql.NullString
+	PullRequestID  sql.NullInt64
+	GhDeploymentID sql.NullInt64
+	GhprCommentID  sql.NullInt64
+	PrName         sql.NullString
+	RepoName       sql.NullString
+	RepoOwner      sql.NullString
+	CommitSha      sql.NullString
+	PrBranchFrom   sql.NullString
+	PrBranchInto   sql.NullString
+	LastErrors     sql.NullString
+}
+
+type DnsRecord struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	SubdomainPrefix sql.NullString
+	RootDomain      sql.NullString
+	Endpoint        sql.NullString
+	Hostname        sql.NullString
+	ClusterID       sql.NullInt64
+}
+
+type Environment struct {
+	ID                   int64
+	CreatedAt            sql.NullTime
+	UpdatedAt            sql.NullTime
+	DeletedAt            sql.NullTime
+	ProjectID            sql.NullInt64
+	ClusterID            sql.NullInt64
+	GitInstallationID    sql.NullInt64
+	GitRepoOwner         sql.NullString
+	GitRepoName          sql.NullString
+	GitRepoBranches      sql.NullString
+	Name                 sql.NullString
+	Mode                 sql.NullString
+	NewCommentsDisabled  sql.NullBool
+	NamespaceLabels      []byte
+	NamespaceAnnotations []byte
+	GitDeployBranches    sql.NullString
+	WebhookID            sql.NullString
+	GithubWebhookID      sql.NullInt64
+}
+
+type EventContainer struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	ReleaseID sql.NullInt64
+}
+
+type GcpIntegration struct {
+	ID           int64
+	CreatedAt    sql.NullTime
+	UpdatedAt    sql.NullTime
+	DeletedAt    sql.NullTime
+	UserID       sql.NullInt64
+	ProjectID    sql.NullInt64
+	GcpProjectID sql.NullString
+	GcpsaEmail   sql.NullString
+	GCpuserEmail sql.NullString
+	GcpRegion    sql.NullString
+	GcpKeyData   []byte
+}
+
+type GitActionConfig struct {
+	ID                   int64
+	CreatedAt            sql.NullTime
+	UpdatedAt            sql.NullTime
+	DeletedAt            sql.NullTime
+	ReleaseID            sql.NullInt64
+	GitRepo              sql.NullString
+	GitBranch            sql.NullString
+	ImageRepoUri         sql.NullString
+	GithubInstallationID sql.NullInt64
+	GitRepoID            sql.NullInt64
+	GitlabIntegrationID  sql.NullInt64
+	DockerfilePath       sql.NullString
+	FolderPath           sql.NullString
+	IsInstallation       sql.NullBool
+	Version              sql.NullString
+}
+
+type GitRepo struct {
+	ID                 int64
+	CreatedAt          sql.NullTime
+	UpdatedAt          sql.NullTime
+	DeletedAt          sql.NullTime
+	ProjectID          sql.NullInt64
+	RepoEntity         sql.NullString
+	OAuthIntegrationID sql.NullInt64
+}
+
+type GithubAppInstallation struct {
+	ID             int64
+	CreatedAt      sql.NullTime
+	UpdatedAt      sql.NullTime
+	DeletedAt      sql.NullTime
+	AccountID      sql.NullInt64
+	InstallationID sql.NullInt64
+}
+
+type GithubAppOAuthIntegration struct {
+	ID           int64
+	CreatedAt    sql.NullTime
+	UpdatedAt    sql.NullTime
+	DeletedAt    sql.NullTime
+	ClientID     []byte
+	AccessToken  []byte
+	RefreshToken []byte
+	Expiry       sql.NullTime
+	UserID       sql.NullInt64
+}
+
+type GitlabAppOAuthIntegration struct {
+	ID                  int64
+	CreatedAt           sql.NullTime
+	UpdatedAt           sql.NullTime
+	DeletedAt           sql.NullTime
+	OAuthIntegrationID  sql.NullInt64
+	GitlabIntegrationID sql.NullInt64
+}
+
+type GitlabIntegration struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	ProjectID       sql.NullInt64
+	InstanceUrl     sql.NullString
+	AppClientID     []byte
+	AppClientSecret []byte
+}
+
+type HelmRepo struct {
+	ID                     int64
+	CreatedAt              sql.NullTime
+	UpdatedAt              sql.NullTime
+	DeletedAt              sql.NullTime
+	Name                   sql.NullString
+	ProjectID              sql.NullInt64
+	RepoUrl                sql.NullString
+	BasicAuthIntegrationID sql.NullInt64
+	GcpIntegrationID       sql.NullInt64
+	AwsIntegrationID       sql.NullInt64
+}
+
+type HelmRepoTokenCach struct {
+	ID         int64
+	CreatedAt  sql.NullTime
+	UpdatedAt  sql.NullTime
+	DeletedAt  sql.NullTime
+	Expiry     sql.NullTime
+	Token      []byte
+	HelmRepoID sql.NullInt64
+}
+
+type Infra struct {
+	ID                 int64
+	CreatedAt          sql.NullTime
+	UpdatedAt          sql.NullTime
+	DeletedAt          sql.NullTime
+	Kind               sql.NullString
+	ApiVersion         sql.NullString
+	SourceLink         sql.NullString
+	SourceVersion      sql.NullString
+	Suffix             sql.NullString
+	ProjectID          sql.NullInt64
+	CreatedByUserID    sql.NullInt64
+	ParentClusterID    sql.NullInt64
+	Status             sql.NullString
+	AwsIntegrationID   sql.NullInt64
+	AzureIntegrationID sql.NullInt64
+	GcpIntegrationID   sql.NullInt64
+	DoIntegrationID    sql.NullInt64
+	DatabaseID         sql.NullInt64
+	LastApplied        []byte
+}
+
+type Invite struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Token     sql.NullString
+	Expiry    sql.NullTime
+	Email     sql.NullString
+	Kind      sql.NullString
+	ProjectID sql.NullInt64
+	UserID    sql.NullInt64
+}
+
+type JobNotificationConfig struct {
+	ID               int64
+	CreatedAt        sql.NullTime
+	UpdatedAt        sql.NullTime
+	DeletedAt        sql.NullTime
+	Name             sql.NullString
+	Namespace        sql.NullString
+	ProjectID        sql.NullInt64
+	ClusterID        sql.NullInt64
+	LastNotifiedTime sql.NullTime
+}
+
+type KubeEvent struct {
+	ID           int64
+	CreatedAt    sql.NullTime
+	UpdatedAt    sql.NullTime
+	DeletedAt    sql.NullTime
+	ProjectID    sql.NullInt64
+	ClusterID    sql.NullInt64
+	Name         sql.NullString
+	ResourceType sql.NullString
+	OwnerType    sql.NullString
+	OwnerName    sql.NullString
+	Namespace    sql.NullString
+}
+
+type KubeIntegration struct {
+	ID                    int64
+	CreatedAt             sql.NullTime
+	UpdatedAt             sql.NullTime
+	DeletedAt             sql.NullTime
+	Mechanism             sql.NullString
+	UserID                sql.NullInt64
+	ProjectID             sql.NullInt64
+	ClientCertificateData []byte
+	ClientKeyData         []byte
+	Token                 []byte
+	Username              []byte
+	Password              []byte
+	Kubeconfig            []byte
+}
+
+type KubeSubEvent struct {
+	ID          int64
+	CreatedAt   sql.NullTime
+	UpdatedAt   sql.NullTime
+	DeletedAt   sql.NullTime
+	KubeEventID sql.NullInt64
+	Message     sql.NullString
+	Reason      sql.NullString
+	Timestamp   sql.NullTime
+	EventType   sql.NullString
+}
+
+type MonitorTestResult struct {
+	ID                   int64
+	CreatedAt            sql.NullTime
+	UpdatedAt            sql.NullTime
+	DeletedAt            sql.NullTime
+	ProjectID            sql.NullInt64
+	ClusterID            sql.NullInt64
+	Category             sql.NullString
+	ObjectID             sql.NullString
+	LastStatusChange     sql.NullTime
+	LastTested           sql.NullTime
+	LastRunResult        sql.NullString
+	LastRunResultEnum    sql.NullInt64
+	LastRecommenderRunID sql.NullString
+	Archived             sql.NullBool
+	Title                sql.NullString
+	Message              sql.NullString
+	Severity             sql.NullString
+	SeverityEnum         sql.NullInt64
+}
+
+type NotificationConfig struct {
+	ID               int64
+	CreatedAt        sql.NullTime
+	UpdatedAt        sql.NullTime
+	DeletedAt        sql.NullTime
+	Enabled          sql.NullBool
+	Success          sql.NullBool
+	Failure          sql.NullBool
+	LastNotifiedTime sql.NullTime
+	NotifLimit       sql.NullString
+}
+
+type OAuthIntegration struct {
+	ID           int64
+	CreatedAt    sql.NullTime
+	UpdatedAt    sql.NullTime
+	DeletedAt    sql.NullTime
+	ClientID     []byte
+	AccessToken  []byte
+	RefreshToken []byte
+	Expiry       sql.NullTime
+	Client       sql.NullString
+	UserID       sql.NullInt64
+	ProjectID    sql.NullInt64
+	TargetEmail  sql.NullString
+	TargetName   sql.NullString
+}
+
+type OIDCIntegration struct {
+	ID                       int64
+	CreatedAt                sql.NullTime
+	UpdatedAt                sql.NullTime
+	DeletedAt                sql.NullTime
+	Client                   sql.NullString
+	UserID                   sql.NullInt64
+	ProjectID                sql.NullInt64
+	IssuerUrl                []byte
+	ClientID                 []byte
+	ClientSecret             []byte
+	CertificateAuthorityData []byte
+	IDToken                  []byte
+	RefreshToken             []byte
+}
+
+type Onboarding struct {
+	ID                             int64
+	CreatedAt                      sql.NullTime
+	UpdatedAt                      sql.NullTime
+	DeletedAt                      sql.NullTime
+	ProjectID                      sql.NullInt64
+	CurrentStep                    sql.NullString
+	ConnectedSource                sql.NullString
+	SkipRegistryConnection         sql.NullBool
+	SkipResourceProvision          sql.NullBool
+	RegistryConnectionID           sql.NullInt64
+	RegistryConnectionCredentialID sql.NullInt64
+	RegistryConnectionProvider     sql.NullString
+	RegistryInfraID                sql.NullInt64
+	RegistryInfraCredentialID      sql.NullInt64
+	RegistryInfraProvider          sql.NullString
+	ClusterInfraID                 sql.NullInt64
+	ClusterInfraCredentialID       sql.NullInt64
+	ClusterInfraProvider           sql.NullString
+}
+
+type Operation struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	Uid             sql.NullString
+	InfraID         sql.NullInt64
+	Type            sql.NullString
+	Status          sql.NullString
+	Errored         sql.NullBool
+	Error           sql.NullString
+	TemplateVersion sql.NullString
+	LastApplied     []byte
+}
+
+type Policy struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	UniqueID        sql.NullString
+	ProjectID       sql.NullInt64
+	CreatedByUserID sql.NullInt64
+	Name            sql.NullString
+	PolicyBytes     []byte
+}
+
+type PorterApp struct {
+	ID             int64
+	CreatedAt      sql.NullTime
+	UpdatedAt      sql.NullTime
+	DeletedAt      sql.NullTime
+	ProjectID      sql.NullInt64
+	ClusterID      sql.NullInt64
+	Name           sql.NullString
+	ImageRepoUri   sql.NullString
+	GitRepoID      sql.NullInt64
+	RepoName       sql.NullString
+	GitBranch      sql.NullString
+	BuildContext   sql.NullString
+	Builder        sql.NullString
+	Buildpacks     sql.NullString
+	Dockerfile     sql.NullString
+	PullRequestUrl sql.NullString
+}
+
+type PorterAppRevision struct {
+	ID             uuid.UUID
+	CreatedAt      time.Time
+	UpdatedAt      time.Time
+	DeletedAt      sql.NullTime
+	Base64Contract string
+	ProjectID      int64
+}
+
+type Project struct {
+	ID                     int64
+	CreatedAt              sql.NullTime
+	UpdatedAt              sql.NullTime
+	DeletedAt              sql.NullTime
+	Name                   sql.NullString
+	ProjectUsageID         sql.NullInt64
+	ProjectUsageCacheID    sql.NullInt64
+	PreviewEnvsEnabled     sql.NullBool
+	RdsDatabasesEnabled    sql.NullBool
+	ManagedInfraEnabled    sql.NullBool
+	StacksEnabled          sql.NullBool
+	ApiTokensEnabled       sql.NullBool
+	CapiProvisionerEnabled sql.NullBool
+	SimplifiedViewEnabled  sql.NullBool
+}
+
+type ProjectBilling struct {
+	ID            int64
+	CreatedAt     sql.NullTime
+	UpdatedAt     sql.NullTime
+	DeletedAt     sql.NullTime
+	ProjectID     sql.NullInt64
+	BillingTeamID sql.NullString
+}
+
+type ProjectUsage struct {
+	ID             int64
+	CreatedAt      sql.NullTime
+	UpdatedAt      sql.NullTime
+	DeletedAt      sql.NullTime
+	ProjectID      sql.NullInt64
+	ResourceCpu    sql.NullInt64
+	ResourceMemory sql.NullInt64
+	Clusters       sql.NullInt64
+	Users          sql.NullInt64
+}
+
+type ProjectUsageCach struct {
+	ID             int64
+	CreatedAt      sql.NullTime
+	UpdatedAt      sql.NullTime
+	DeletedAt      sql.NullTime
+	ProjectID      sql.NullInt64
+	ResourceCpu    sql.NullInt64
+	ResourceMemory sql.NullInt64
+	Clusters       sql.NullInt64
+	Users          sql.NullInt64
+	Exceeded       sql.NullBool
+	ExceededSince  sql.NullTime
+}
+
+type PwResetToken struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Email     sql.NullString
+	IsValid   sql.NullBool
+	Expiry    sql.NullTime
+	Token     sql.NullString
+}
+
+type RegTokenCach struct {
+	ID         int64
+	CreatedAt  sql.NullTime
+	UpdatedAt  sql.NullTime
+	DeletedAt  sql.NullTime
+	Expiry     sql.NullTime
+	Token      []byte
+	RegistryID sql.NullInt64
+}
+
+type Registry struct {
+	ID                 int64
+	CreatedAt          sql.NullTime
+	UpdatedAt          sql.NullTime
+	DeletedAt          sql.NullTime
+	Name               sql.NullString
+	Url                sql.NullString
+	ProjectID          sql.NullInt64
+	InfraID            sql.NullInt64
+	GcpIntegrationID   sql.NullInt64
+	AwsIntegrationID   sql.NullInt64
+	AzureIntegrationID sql.NullInt64
+	DoIntegrationID    sql.NullInt64
+	BasicIntegrationID sql.NullInt64
+}
+
+type Release struct {
+	ID                 int64
+	CreatedAt          sql.NullTime
+	UpdatedAt          sql.NullTime
+	DeletedAt          sql.NullTime
+	WebhookToken       sql.NullString
+	ClusterID          sql.NullInt64
+	ProjectID          sql.NullInt64
+	Name               sql.NullString
+	Namespace          sql.NullString
+	StackResourceID    sql.NullInt64
+	ImageRepoUri       sql.NullString
+	EventContainer     sql.NullInt64
+	NotificationConfig sql.NullInt64
+	BuildConfig        sql.NullInt64
+	CanonicalName      sql.NullString
+}
+
+type ReleaseTag struct {
+	TagID     int64
+	ReleaseID int64
+}
+
+type Role struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Kind      sql.NullString
+	UserID    sql.NullInt64
+	ProjectID sql.NullInt64
+}
+
+type Session struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Key       sql.NullString
+	Data      []byte
+	ExpiresAt sql.NullTime
+}
+
+type SlackIntegration struct {
+	ID               int64
+	CreatedAt        sql.NullTime
+	UpdatedAt        sql.NullTime
+	DeletedAt        sql.NullTime
+	ClientID         []byte
+	AccessToken      []byte
+	RefreshToken     []byte
+	Expiry           sql.NullTime
+	Client           sql.NullString
+	UserID           sql.NullInt64
+	ProjectID        sql.NullInt64
+	TeamID           sql.NullString
+	TeamName         sql.NullString
+	TeamIconUrl      sql.NullString
+	Channel          sql.NullString
+	ChannelID        sql.NullString
+	ConfigurationUrl sql.NullString
+	Webhook          []byte
+}
+
+type Stack struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	ProjectID sql.NullInt64
+	ClusterID sql.NullInt64
+	Namespace sql.NullString
+	Name      sql.NullString
+	Uid       sql.NullString
+}
+
+type StackEnvGroup struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	StackRevisionID sql.NullInt64
+	Name            sql.NullString
+	Namespace       sql.NullString
+	ProjectID       sql.NullInt64
+	ClusterID       sql.NullInt64
+	Uid             sql.NullString
+	EnvGroupVersion sql.NullInt64
+}
+
+type StackResource struct {
+	ID                   int64
+	CreatedAt            sql.NullTime
+	UpdatedAt            sql.NullTime
+	DeletedAt            sql.NullTime
+	Name                 sql.NullString
+	Uid                  sql.NullString
+	StackRevisionID      sql.NullInt64
+	StackSourceConfigUid sql.NullString
+	HelmRevisionID       sql.NullInt64
+	Values               []byte
+	TemplateRepoUrl      sql.NullString
+	TemplateName         sql.NullString
+	TemplateVersion      sql.NullString
+}
+
+type StackRevision struct {
+	ID             int64
+	CreatedAt      sql.NullTime
+	UpdatedAt      sql.NullTime
+	DeletedAt      sql.NullTime
+	RevisionNumber sql.NullInt64
+	StackID        sql.NullInt64
+	Status         sql.NullString
+	Reason         sql.NullString
+	Message        sql.NullString
+}
+
+type StackSourceConfig struct {
+	ID              int64
+	CreatedAt       sql.NullTime
+	UpdatedAt       sql.NullTime
+	DeletedAt       sql.NullTime
+	StackRevisionID sql.NullInt64
+	Name            sql.NullString
+	DisplayName     sql.NullString
+	Uid             sql.NullString
+	ImageRepoUri    sql.NullString
+	ImageTag        sql.NullString
+}
+
+type SubEvent struct {
+	ID               int64
+	CreatedAt        sql.NullTime
+	UpdatedAt        sql.NullTime
+	DeletedAt        sql.NullTime
+	EventContainerID sql.NullInt64
+	EventID          sql.NullString
+	Name             sql.NullString
+	Index            sql.NullInt64
+	Status           sql.NullInt64
+	Info             sql.NullString
+}
+
+type Tag struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	ProjectID sql.NullInt64
+	Name      sql.NullString
+	Color     sql.NullString
+}
+
+type TokenCach struct {
+	ID        int64
+	CreatedAt sql.NullTime
+	UpdatedAt sql.NullTime
+	DeletedAt sql.NullTime
+	Expiry    sql.NullTime
+	Token     []byte
+}
+
+type User struct {
+	ID                     int64
+	CreatedAt              sql.NullTime
+	UpdatedAt              sql.NullTime
+	DeletedAt              sql.NullTime
+	Email                  sql.NullString
+	Password               sql.NullString
+	EmailVerified          sql.NullBool
+	FirstName              sql.NullString
+	LastName               sql.NullString
+	CompanyName            sql.NullString
+	GithubAppIntegrationID sql.NullInt64
+	GithubUserID           sql.NullInt64
+	GoogleUserID           sql.NullString
+}
+
+type UserBilling struct {
+	ID         int64
+	CreatedAt  sql.NullTime
+	UpdatedAt  sql.NullTime
+	DeletedAt  sql.NullTime
+	ProjectID  sql.NullInt64
+	UserID     sql.NullInt64
+	TeammateID sql.NullString
+	Token      []byte
+}

+ 71 - 0
database/generated/queries/porter_app_revisions.sql.go

@@ -0,0 +1,71 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.18.0
+// source: porter_app_revisions.sql
+
+package queries
+
+import (
+	"context"
+)
+
+const createPorterAppRevision = `-- name: CreatePorterAppRevision :one
+INSERT INTO porter_app_revisions 
+(project_id, base64_contract) 
+VALUES 
+($1, $2) RETURNING id, created_at, updated_at, deleted_at, base64_contract, project_id
+`
+
+type CreatePorterAppRevisionParams struct {
+	ProjectID      int64
+	Base64Contract string
+}
+
+func (q *Queries) CreatePorterAppRevision(ctx context.Context, arg CreatePorterAppRevisionParams) (PorterAppRevision, error) {
+	row := q.db.QueryRowContext(ctx, createPorterAppRevision, arg.ProjectID, arg.Base64Contract)
+	var i PorterAppRevision
+	err := row.Scan(
+		&i.ID,
+		&i.CreatedAt,
+		&i.UpdatedAt,
+		&i.DeletedAt,
+		&i.Base64Contract,
+		&i.ProjectID,
+	)
+	return i, err
+}
+
+const porterAppRevisionsForProject = `-- name: PorterAppRevisionsForProject :many
+SELECT id, created_at, updated_at, deleted_at, base64_contract, project_id FROM porter_app_revisions
+WHERE project_id = $1 AND deleted_at IS NULL
+`
+
+func (q *Queries) PorterAppRevisionsForProject(ctx context.Context, projectID int64) ([]PorterAppRevision, error) {
+	rows, err := q.db.QueryContext(ctx, porterAppRevisionsForProject, projectID)
+	if err != nil {
+		return nil, err
+	}
+	defer rows.Close()
+	var items []PorterAppRevision
+	for rows.Next() {
+		var i PorterAppRevision
+		if err := rows.Scan(
+			&i.ID,
+			&i.CreatedAt,
+			&i.UpdatedAt,
+			&i.DeletedAt,
+			&i.Base64Contract,
+			&i.ProjectID,
+		); err != nil {
+			return nil, err
+		}
+		items = append(items, i)
+	}
+	if err := rows.Close(); err != nil {
+		return nil, err
+	}
+	if err := rows.Err(); err != nil {
+		return nil, err
+	}
+	return items, nil
+}

+ 1154 - 0
database/migrations/20230503225831.sql

@@ -0,0 +1,1154 @@
+-- Create "deployments" table
+CREATE TABLE "public"."deployments" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "environment_id" bigint NULL,
+ "namespace" text NULL,
+ "status" text NULL,
+ "subdomain" text NULL,
+ "pull_request_id" bigint NULL,
+ "gh_deployment_id" bigint NULL,
+ "ghpr_comment_id" bigint NULL,
+ "pr_name" text NULL,
+ "repo_name" text NULL,
+ "repo_owner" text NULL,
+ "commit_sha" text NULL,
+ "pr_branch_from" text NULL,
+ "pr_branch_into" text NULL,
+ "last_errors" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_deployments_deleted_at" to table: "deployments"
+CREATE INDEX "idx_deployments_deleted_at" ON "public"."deployments" ("deleted_at");
+-- Create "token_caches" table
+CREATE TABLE "public"."token_caches" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "expiry" timestamptz NULL,
+ "token" bytea NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_token_caches_deleted_at" to table: "token_caches"
+CREATE INDEX "idx_token_caches_deleted_at" ON "public"."token_caches" ("deleted_at");
+-- Create "api_tokens" table
+CREATE TABLE "public"."api_tokens" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "unique_id" text NULL,
+ "project_id" bigint NULL,
+ "created_by_user_id" bigint NULL,
+ "expiry" timestamptz NULL,
+ "revoked" boolean NULL,
+ "policy_uid" text NULL,
+ "policy_name" text NULL,
+ "name" text NULL,
+ "secret_key" bytea NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "api_tokens_unique_id_key" to table: "api_tokens"
+CREATE UNIQUE INDEX "api_tokens_unique_id_key" ON "public"."api_tokens" ("unique_id");
+-- Create index "idx_api_tokens_deleted_at" to table: "api_tokens"
+CREATE INDEX "idx_api_tokens_deleted_at" ON "public"."api_tokens" ("deleted_at");
+-- Create "auth_codes" table
+CREATE TABLE "public"."auth_codes" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "token" text NULL,
+ "authorization_code" text NULL,
+ "expiry" timestamptz NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "auth_codes_authorization_code_key" to table: "auth_codes"
+CREATE UNIQUE INDEX "auth_codes_authorization_code_key" ON "public"."auth_codes" ("authorization_code");
+-- Create index "auth_codes_token_key" to table: "auth_codes"
+CREATE UNIQUE INDEX "auth_codes_token_key" ON "public"."auth_codes" ("token");
+-- Create index "idx_auth_codes_deleted_at" to table: "auth_codes"
+CREATE INDEX "idx_auth_codes_deleted_at" ON "public"."auth_codes" ("deleted_at");
+-- Create "policies" table
+CREATE TABLE "public"."policies" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "unique_id" text NULL,
+ "project_id" bigint NULL,
+ "created_by_user_id" bigint NULL,
+ "name" text NULL,
+ "policy_bytes" bytea NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_policies_deleted_at" to table: "policies"
+CREATE INDEX "idx_policies_deleted_at" ON "public"."policies" ("deleted_at");
+-- Create index "policies_unique_id_key" to table: "policies"
+CREATE UNIQUE INDEX "policies_unique_id_key" ON "public"."policies" ("unique_id");
+-- Create "porter_apps" table
+CREATE TABLE "public"."porter_apps" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "name" text NULL,
+ "image_repo_uri" text NULL,
+ "git_repo_id" bigint NULL,
+ "repo_name" text NULL,
+ "git_branch" text NULL,
+ "build_context" text NULL,
+ "builder" text NULL,
+ "buildpacks" text NULL,
+ "dockerfile" text NULL,
+ "pull_request_url" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_porter_apps_deleted_at" to table: "porter_apps"
+CREATE INDEX "idx_porter_apps_deleted_at" ON "public"."porter_apps" ("deleted_at");
+-- Create "user_billings" table
+CREATE TABLE "public"."user_billings" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "user_id" bigint NULL,
+ "teammate_id" text NULL,
+ "token" bytea NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_user_billings_deleted_at" to table: "user_billings"
+CREATE INDEX "idx_user_billings_deleted_at" ON "public"."user_billings" ("deleted_at");
+-- Create "dns_records" table
+CREATE TABLE "public"."dns_records" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "subdomain_prefix" text NULL,
+ "root_domain" text NULL,
+ "endpoint" text NULL,
+ "hostname" text NULL,
+ "cluster_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "dns_records_subdomain_prefix_key" to table: "dns_records"
+CREATE UNIQUE INDEX "dns_records_subdomain_prefix_key" ON "public"."dns_records" ("subdomain_prefix");
+-- Create index "idx_dns_records_deleted_at" to table: "dns_records"
+CREATE INDEX "idx_dns_records_deleted_at" ON "public"."dns_records" ("deleted_at");
+-- Create "build_configs" table
+CREATE TABLE "public"."build_configs" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "name" text NULL,
+ "builder" text NULL,
+ "buildpacks" text NULL,
+ "config" bytea NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_build_configs_deleted_at" to table: "build_configs"
+CREATE INDEX "idx_build_configs_deleted_at" ON "public"."build_configs" ("deleted_at");
+-- Create "environments" table
+CREATE TABLE "public"."environments" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "git_installation_id" bigint NULL,
+ "git_repo_owner" text NULL,
+ "git_repo_name" text NULL,
+ "git_repo_branches" text NULL,
+ "name" text NULL,
+ "mode" text NULL,
+ "new_comments_disabled" boolean NULL,
+ "namespace_labels" bytea NULL,
+ "namespace_annotations" bytea NULL,
+ "git_deploy_branches" text NULL,
+ "webhook_id" text NULL,
+ "github_webhook_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "environments_webhook_id_key" to table: "environments"
+CREATE UNIQUE INDEX "environments_webhook_id_key" ON "public"."environments" ("webhook_id");
+-- Create index "idx_environments_deleted_at" to table: "environments"
+CREATE INDEX "idx_environments_deleted_at" ON "public"."environments" ("deleted_at");
+-- Create "project_billings" table
+CREATE TABLE "public"."project_billings" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "billing_team_id" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_project_billings_deleted_at" to table: "project_billings"
+CREATE INDEX "idx_project_billings_deleted_at" ON "public"."project_billings" ("deleted_at");
+-- Create "cluster_token_caches" table
+CREATE TABLE "public"."cluster_token_caches" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "expiry" timestamptz NULL,
+ "token" bytea NULL,
+ "cluster_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_cluster_token_caches_deleted_at" to table: "cluster_token_caches"
+CREATE INDEX "idx_cluster_token_caches_deleted_at" ON "public"."cluster_token_caches" ("deleted_at");
+-- Create "slack_integrations" table
+CREATE TABLE "public"."slack_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "client_id" bytea NULL,
+ "access_token" bytea NULL,
+ "refresh_token" bytea NULL,
+ "expiry" timestamptz NULL,
+ "client" text NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "team_id" text NULL,
+ "team_name" text NULL,
+ "team_icon_url" text NULL,
+ "channel" text NULL,
+ "channel_id" text NULL,
+ "configuration_url" text NULL,
+ "webhook" bytea NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_slack_integrations_deleted_at" to table: "slack_integrations"
+CREATE INDEX "idx_slack_integrations_deleted_at" ON "public"."slack_integrations" ("deleted_at");
+-- Create "credentials_exchange_tokens" table
+CREATE TABLE "public"."credentials_exchange_tokens" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "token" bytea NULL,
+ "expiry" timestamptz NULL,
+ "do_credential_id" bigint NULL,
+ "aws_credential_id" bigint NULL,
+ "gcp_credential_id" bigint NULL,
+ "azure_credential_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_credentials_exchange_tokens_deleted_at" to table: "credentials_exchange_tokens"
+CREATE INDEX "idx_credentials_exchange_tokens_deleted_at" ON "public"."credentials_exchange_tokens" ("deleted_at");
+-- Create "sessions" table
+CREATE TABLE "public"."sessions" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "key" text NULL,
+ "data" bytea NULL,
+ "expires_at" timestamptz NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_sessions_deleted_at" to table: "sessions"
+CREATE INDEX "idx_sessions_deleted_at" ON "public"."sessions" ("deleted_at");
+-- Create index "sessions_key_key" to table: "sessions"
+CREATE UNIQUE INDEX "sessions_key_key" ON "public"."sessions" ("key");
+-- Create "db_migrations" table
+CREATE TABLE "public"."db_migrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "version" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_db_migrations_deleted_at" to table: "db_migrations"
+CREATE INDEX "idx_db_migrations_deleted_at" ON "public"."db_migrations" ("deleted_at");
+-- Create "users" table
+CREATE TABLE "public"."users" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "email" text NULL,
+ "password" text NULL,
+ "email_verified" boolean NULL,
+ "first_name" text NULL,
+ "last_name" text NULL,
+ "company_name" text NULL,
+ "github_app_integration_id" bigint NULL,
+ "github_user_id" bigint NULL,
+ "google_user_id" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_users_deleted_at" to table: "users"
+CREATE INDEX "idx_users_deleted_at" ON "public"."users" ("deleted_at");
+-- Create index "users_email_key" to table: "users"
+CREATE UNIQUE INDEX "users_email_key" ON "public"."users" ("email");
+-- Create "api_contract_revisions" table
+CREATE TABLE "public"."api_contract_revisions" (
+ "id" uuid NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "base64_contract" text NULL,
+ "cluster_id" bigint NULL,
+ "project_id" bigint NULL,
+ "condition" text NULL,
+ "condition_metadata" jsonb NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_api_contract_revisions_deleted_at" to table: "api_contract_revisions"
+CREATE INDEX "idx_api_contract_revisions_deleted_at" ON "public"."api_contract_revisions" ("deleted_at");
+-- Create "onboardings" table
+CREATE TABLE "public"."onboardings" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "current_step" text NULL,
+ "connected_source" text NULL,
+ "skip_registry_connection" boolean NULL,
+ "skip_resource_provision" boolean NULL,
+ "registry_connection_id" bigint NULL,
+ "registry_connection_credential_id" bigint NULL,
+ "registry_connection_provider" text NULL,
+ "registry_infra_id" bigint NULL,
+ "registry_infra_credential_id" bigint NULL,
+ "registry_infra_provider" text NULL,
+ "cluster_infra_id" bigint NULL,
+ "cluster_infra_credential_id" bigint NULL,
+ "cluster_infra_provider" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_onboardings_deleted_at" to table: "onboardings"
+CREATE INDEX "idx_onboardings_deleted_at" ON "public"."onboardings" ("deleted_at");
+-- Create "allowlists" table
+CREATE TABLE "public"."allowlists" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "user_email" text NOT NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "allowlists_user_email_key" to table: "allowlists"
+CREATE UNIQUE INDEX "allowlists_user_email_key" ON "public"."allowlists" ("user_email");
+-- Create index "idx_allowlists_deleted_at" to table: "allowlists"
+CREATE INDEX "idx_allowlists_deleted_at" ON "public"."allowlists" ("deleted_at");
+-- Create "pw_reset_tokens" table
+CREATE TABLE "public"."pw_reset_tokens" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "email" text NULL,
+ "is_valid" boolean NULL,
+ "expiry" timestamptz NULL,
+ "token" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_pw_reset_tokens_deleted_at" to table: "pw_reset_tokens"
+CREATE INDEX "idx_pw_reset_tokens_deleted_at" ON "public"."pw_reset_tokens" ("deleted_at");
+-- Create "projects" table
+CREATE TABLE "public"."projects" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "name" text NULL,
+ "project_usage_id" bigint NULL,
+ "project_usage_cache_id" bigint NULL,
+ "preview_envs_enabled" boolean NULL,
+ "rds_databases_enabled" boolean NULL,
+ "managed_infra_enabled" boolean NULL,
+ "stacks_enabled" boolean NULL,
+ "api_tokens_enabled" boolean NULL,
+ "capi_provisioner_enabled" boolean NULL,
+ "simplified_view_enabled" boolean NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_projects_deleted_at" to table: "projects"
+CREATE INDEX "idx_projects_deleted_at" ON "public"."projects" ("deleted_at");
+-- Create "job_notification_configs" table
+CREATE TABLE "public"."job_notification_configs" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "name" text NULL,
+ "namespace" text NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "last_notified_time" timestamptz NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_job_notification_configs_deleted_at" to table: "job_notification_configs"
+CREATE INDEX "idx_job_notification_configs_deleted_at" ON "public"."job_notification_configs" ("deleted_at");
+-- Create "github_app_installations" table
+CREATE TABLE "public"."github_app_installations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "account_id" bigint NULL,
+ "installation_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "github_app_installations_account_id_key" to table: "github_app_installations"
+CREATE UNIQUE INDEX "github_app_installations_account_id_key" ON "public"."github_app_installations" ("account_id");
+-- Create index "idx_github_app_installations_deleted_at" to table: "github_app_installations"
+CREATE INDEX "idx_github_app_installations_deleted_at" ON "public"."github_app_installations" ("deleted_at");
+-- Create "github_app_o_auth_integrations" table
+CREATE TABLE "public"."github_app_o_auth_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "client_id" bytea NULL,
+ "access_token" bytea NULL,
+ "refresh_token" bytea NULL,
+ "expiry" timestamptz NULL,
+ "user_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_github_app_o_auth_integrations_deleted_at" to table: "github_app_o_auth_integrations"
+CREATE INDEX "idx_github_app_o_auth_integrations_deleted_at" ON "public"."github_app_o_auth_integrations" ("deleted_at");
+-- Create "gitlab_app_o_auth_integrations" table
+CREATE TABLE "public"."gitlab_app_o_auth_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "o_auth_integration_id" bigint NULL,
+ "gitlab_integration_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_gitlab_app_o_auth_integrations_deleted_at" to table: "gitlab_app_o_auth_integrations"
+CREATE INDEX "idx_gitlab_app_o_auth_integrations_deleted_at" ON "public"."gitlab_app_o_auth_integrations" ("deleted_at");
+-- Create "project_usages" table
+CREATE TABLE "public"."project_usages" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "resource_cpu" bigint NULL,
+ "resource_memory" bigint NULL,
+ "clusters" bigint NULL,
+ "users" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_project_usages_deleted_at" to table: "project_usages"
+CREATE INDEX "idx_project_usages_deleted_at" ON "public"."project_usages" ("deleted_at");
+-- Create "notification_configs" table
+CREATE TABLE "public"."notification_configs" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "enabled" boolean NULL,
+ "success" boolean NULL,
+ "failure" boolean NULL,
+ "last_notified_time" timestamptz NULL,
+ "notif_limit" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_notification_configs_deleted_at" to table: "notification_configs"
+CREATE INDEX "idx_notification_configs_deleted_at" ON "public"."notification_configs" ("deleted_at");
+-- Create "monitor_test_results" table
+CREATE TABLE "public"."monitor_test_results" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "category" text NULL,
+ "object_id" text NULL,
+ "last_status_change" timestamptz NULL,
+ "last_tested" timestamptz NULL,
+ "last_run_result" text NULL,
+ "last_run_result_enum" bigint NULL,
+ "last_recommender_run_id" text NULL,
+ "archived" boolean NULL,
+ "title" text NULL,
+ "message" text NULL,
+ "severity" text NULL,
+ "severity_enum" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_monitor_test_results_deleted_at" to table: "monitor_test_results"
+CREATE INDEX "idx_monitor_test_results_deleted_at" ON "public"."monitor_test_results" ("deleted_at");
+-- Create "project_usage_caches" table
+CREATE TABLE "public"."project_usage_caches" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "resource_cpu" bigint NULL,
+ "resource_memory" bigint NULL,
+ "clusters" bigint NULL,
+ "users" bigint NULL,
+ "exceeded" boolean NULL,
+ "exceeded_since" timestamptz NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_project_usage_caches_deleted_at" to table: "project_usage_caches"
+CREATE INDEX "idx_project_usage_caches_deleted_at" ON "public"."project_usage_caches" ("deleted_at");
+-- Create "aws_integrations" table
+CREATE TABLE "public"."aws_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "aws_arn" text NULL,
+ "aws_region" text NULL,
+ "aws_assume_role_arn" text NULL,
+ "aws_cluster_id" bytea NULL,
+ "aws_access_key_id" bytea NULL,
+ "aws_secret_access_key" bytea NULL,
+ "aws_session_token" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_aws_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_aws_integrations_deleted_at" to table: "aws_integrations"
+CREATE INDEX "idx_aws_integrations_deleted_at" ON "public"."aws_integrations" ("deleted_at");
+-- Create "git_repos" table
+CREATE TABLE "public"."git_repos" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "repo_entity" text NULL,
+ "o_auth_integration_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_git_repos" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_git_repos_deleted_at" to table: "git_repos"
+CREATE INDEX "idx_git_repos_deleted_at" ON "public"."git_repos" ("deleted_at");
+-- Create "infras" table
+CREATE TABLE "public"."infras" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "kind" text NULL,
+ "api_version" text NULL,
+ "source_link" text NULL,
+ "source_version" text NULL,
+ "suffix" text NULL,
+ "project_id" bigint NULL,
+ "created_by_user_id" bigint NULL,
+ "parent_cluster_id" bigint NULL,
+ "status" text NULL,
+ "aws_integration_id" bigint NULL,
+ "azure_integration_id" bigint NULL,
+ "gcp_integration_id" bigint NULL,
+ "do_integration_id" bigint NULL,
+ "database_id" bigint NULL,
+ "last_applied" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_infras" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_infras_deleted_at" to table: "infras"
+CREATE INDEX "idx_infras_deleted_at" ON "public"."infras" ("deleted_at");
+-- Create "operations" table
+CREATE TABLE "public"."operations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "uid" text NULL,
+ "infra_id" bigint NULL,
+ "type" text NULL,
+ "status" text NULL,
+ "errored" boolean NULL,
+ "error" text NULL,
+ "template_version" text NULL,
+ "last_applied" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_infras_operations" FOREIGN KEY ("infra_id") REFERENCES "public"."infras" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_operations_deleted_at" to table: "operations"
+CREATE INDEX "idx_operations_deleted_at" ON "public"."operations" ("deleted_at");
+-- Create index "operations_uid_key" to table: "operations"
+CREATE UNIQUE INDEX "operations_uid_key" ON "public"."operations" ("uid");
+-- Create "cluster_candidates" table
+CREATE TABLE "public"."cluster_candidates" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "auth_mechanism" text NULL,
+ "project_id" bigint NULL,
+ "created_cluster_id" bigint NULL,
+ "name" text NULL,
+ "server" text NULL,
+ "context_name" text NULL,
+ "aws_cluster_id_guess" bytea NULL,
+ "kubeconfig" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_cluster_candidates" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_cluster_candidates_deleted_at" to table: "cluster_candidates"
+CREATE INDEX "idx_cluster_candidates_deleted_at" ON "public"."cluster_candidates" ("deleted_at");
+-- Create "cluster_resolvers" table
+CREATE TABLE "public"."cluster_resolvers" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "cluster_candidate_id" bigint NULL,
+ "name" text NULL,
+ "resolved" boolean NULL,
+ "data" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_cluster_candidates_resolvers" FOREIGN KEY ("cluster_candidate_id") REFERENCES "public"."cluster_candidates" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_cluster_resolvers_deleted_at" to table: "cluster_resolvers"
+CREATE INDEX "idx_cluster_resolvers_deleted_at" ON "public"."cluster_resolvers" ("deleted_at");
+-- Create "helm_repos" table
+CREATE TABLE "public"."helm_repos" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "name" text NULL,
+ "project_id" bigint NULL,
+ "repo_url" text NULL,
+ "basic_auth_integration_id" bigint NULL,
+ "gcp_integration_id" bigint NULL,
+ "aws_integration_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_helm_repos" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_helm_repos_deleted_at" to table: "helm_repos"
+CREATE INDEX "idx_helm_repos_deleted_at" ON "public"."helm_repos" ("deleted_at");
+-- Create "helm_repo_token_caches" table
+CREATE TABLE "public"."helm_repo_token_caches" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "expiry" timestamptz NULL,
+ "token" bytea NULL,
+ "helm_repo_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_helm_repos_token_cache" FOREIGN KEY ("helm_repo_id") REFERENCES "public"."helm_repos" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_helm_repo_token_caches_deleted_at" to table: "helm_repo_token_caches"
+CREATE INDEX "idx_helm_repo_token_caches_deleted_at" ON "public"."helm_repo_token_caches" ("deleted_at");
+-- Create "o_auth_integrations" table
+CREATE TABLE "public"."o_auth_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "client_id" bytea NULL,
+ "access_token" bytea NULL,
+ "refresh_token" bytea NULL,
+ "expiry" timestamptz NULL,
+ "client" text NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "target_email" text NULL,
+ "target_name" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_o_auth_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_o_auth_integrations_deleted_at" to table: "o_auth_integrations"
+CREATE INDEX "idx_o_auth_integrations_deleted_at" ON "public"."o_auth_integrations" ("deleted_at");
+-- Create "registries" table
+CREATE TABLE "public"."registries" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "name" text NULL,
+ "url" text NULL,
+ "project_id" bigint NULL,
+ "infra_id" bigint NULL,
+ "gcp_integration_id" bigint NULL,
+ "aws_integration_id" bigint NULL,
+ "azure_integration_id" bigint NULL,
+ "do_integration_id" bigint NULL,
+ "basic_integration_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_registries" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_registries_deleted_at" to table: "registries"
+CREATE INDEX "idx_registries_deleted_at" ON "public"."registries" ("deleted_at");
+-- Create "reg_token_caches" table
+CREATE TABLE "public"."reg_token_caches" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "expiry" timestamptz NULL,
+ "token" bytea NULL,
+ "registry_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_registries_token_cache" FOREIGN KEY ("registry_id") REFERENCES "public"."registries" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_reg_token_caches_deleted_at" to table: "reg_token_caches"
+CREATE INDEX "idx_reg_token_caches_deleted_at" ON "public"."reg_token_caches" ("deleted_at");
+-- Create "event_containers" table
+CREATE TABLE "public"."event_containers" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "release_id" bigint NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_event_containers_deleted_at" to table: "event_containers"
+CREATE INDEX "idx_event_containers_deleted_at" ON "public"."event_containers" ("deleted_at");
+-- Create "sub_events" table
+CREATE TABLE "public"."sub_events" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "event_container_id" bigint NULL,
+ "event_id" text NULL,
+ "name" text NULL,
+ "index" bigint NULL,
+ "status" bigint NULL,
+ "info" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_event_containers_steps" FOREIGN KEY ("event_container_id") REFERENCES "public"."event_containers" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_sub_events_deleted_at" to table: "sub_events"
+CREATE INDEX "idx_sub_events_deleted_at" ON "public"."sub_events" ("deleted_at");
+-- Create "kube_integrations" table
+CREATE TABLE "public"."kube_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "mechanism" text NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "client_certificate_data" bytea NULL,
+ "client_key_data" bytea NULL,
+ "token" bytea NULL,
+ "username" bytea NULL,
+ "password" bytea NULL,
+ "kubeconfig" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_kube_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_kube_integrations_deleted_at" to table: "kube_integrations"
+CREATE INDEX "idx_kube_integrations_deleted_at" ON "public"."kube_integrations" ("deleted_at");
+-- Create "o_id_c_integrations" table
+CREATE TABLE "public"."o_id_c_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "client" text NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "issuer_url" bytea NULL,
+ "client_id" bytea NULL,
+ "client_secret" bytea NULL,
+ "certificate_authority_data" bytea NULL,
+ "id_token" bytea NULL,
+ "refresh_token" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_o_id_c_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_o_id_c_integrations_deleted_at" to table: "o_id_c_integrations"
+CREATE INDEX "idx_o_id_c_integrations_deleted_at" ON "public"."o_id_c_integrations" ("deleted_at");
+-- Create "releases" table
+CREATE TABLE "public"."releases" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "webhook_token" text NULL,
+ "cluster_id" bigint NULL,
+ "project_id" bigint NULL,
+ "name" text NULL,
+ "namespace" text NULL,
+ "stack_resource_id" bigint NULL,
+ "image_repo_uri" text NULL,
+ "event_container" bigint NULL,
+ "notification_config" bigint NULL,
+ "build_config" bigint NULL,
+ "canonical_name" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_releases_deleted_at" to table: "releases"
+CREATE INDEX "idx_releases_deleted_at" ON "public"."releases" ("deleted_at");
+-- Create index "releases_webhook_token_key" to table: "releases"
+CREATE UNIQUE INDEX "releases_webhook_token_key" ON "public"."releases" ("webhook_token");
+-- Create "git_action_configs" table
+CREATE TABLE "public"."git_action_configs" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "release_id" bigint NULL,
+ "git_repo" text NULL,
+ "git_branch" text NULL,
+ "image_repo_uri" text NULL,
+ "github_installation_id" bigint NULL,
+ "git_repo_id" bigint NULL,
+ "gitlab_integration_id" bigint NULL,
+ "dockerfile_path" text NULL,
+ "folder_path" text NULL,
+ "is_installation" boolean NULL,
+ "version" text NULL DEFAULT 'v0.0.1',
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_releases_git_action_config" FOREIGN KEY ("release_id") REFERENCES "public"."releases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_git_action_configs_deleted_at" to table: "git_action_configs"
+CREATE INDEX "idx_git_action_configs_deleted_at" ON "public"."git_action_configs" ("deleted_at");
+-- Create "kube_events" table
+CREATE TABLE "public"."kube_events" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "name" text NULL,
+ "resource_type" text NULL,
+ "owner_type" text NULL,
+ "owner_name" text NULL,
+ "namespace" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_kube_events_deleted_at" to table: "kube_events"
+CREATE INDEX "idx_kube_events_deleted_at" ON "public"."kube_events" ("deleted_at");
+-- Create "kube_sub_events" table
+CREATE TABLE "public"."kube_sub_events" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "kube_event_id" bigint NULL,
+ "message" text NULL,
+ "reason" text NULL,
+ "timestamp" timestamptz NULL,
+ "event_type" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_kube_events_sub_events" FOREIGN KEY ("kube_event_id") REFERENCES "public"."kube_events" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_kube_sub_events_deleted_at" to table: "kube_sub_events"
+CREATE INDEX "idx_kube_sub_events_deleted_at" ON "public"."kube_sub_events" ("deleted_at");
+-- Create "tags" table
+CREATE TABLE "public"."tags" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "name" text NULL,
+ "color" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_tags_deleted_at" to table: "tags"
+CREATE INDEX "idx_tags_deleted_at" ON "public"."tags" ("deleted_at");
+-- Create "release_tags" table
+CREATE TABLE "public"."release_tags" (
+ "tag_id" bigint NOT NULL,
+ "release_id" bigint NOT NULL,
+ PRIMARY KEY ("tag_id", "release_id"),
+ CONSTRAINT "fk_release_tags_release" FOREIGN KEY ("release_id") REFERENCES "public"."releases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT "fk_release_tags_tag" FOREIGN KEY ("tag_id") REFERENCES "public"."tags" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create "stacks" table
+CREATE TABLE "public"."stacks" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "namespace" text NULL,
+ "name" text NULL,
+ "uid" text NULL,
+ PRIMARY KEY ("id")
+);
+-- Create index "idx_stacks_deleted_at" to table: "stacks"
+CREATE INDEX "idx_stacks_deleted_at" ON "public"."stacks" ("deleted_at");
+-- Create index "stacks_uid_key" to table: "stacks"
+CREATE UNIQUE INDEX "stacks_uid_key" ON "public"."stacks" ("uid");
+-- Create "stack_revisions" table
+CREATE TABLE "public"."stack_revisions" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "revision_number" bigint NULL,
+ "stack_id" bigint NULL,
+ "status" text NULL,
+ "reason" text NULL,
+ "message" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_stacks_revisions" FOREIGN KEY ("stack_id") REFERENCES "public"."stacks" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_revisions_deleted_at" to table: "stack_revisions"
+CREATE INDEX "idx_stack_revisions_deleted_at" ON "public"."stack_revisions" ("deleted_at");
+-- Create "stack_env_groups" table
+CREATE TABLE "public"."stack_env_groups" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "stack_revision_id" bigint NULL,
+ "name" text NULL,
+ "namespace" text NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "uid" text NULL,
+ "env_group_version" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_stack_revisions_env_groups" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_env_groups_deleted_at" to table: "stack_env_groups"
+CREATE INDEX "idx_stack_env_groups_deleted_at" ON "public"."stack_env_groups" ("deleted_at");
+-- Create "stack_resources" table
+CREATE TABLE "public"."stack_resources" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "name" text NULL,
+ "uid" text NULL,
+ "stack_revision_id" bigint NULL,
+ "stack_source_config_uid" text NULL,
+ "helm_revision_id" bigint NULL,
+ "values" bytea NULL,
+ "template_repo_url" text NULL,
+ "template_name" text NULL,
+ "template_version" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_stack_revisions_resources" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_resources_deleted_at" to table: "stack_resources"
+CREATE INDEX "idx_stack_resources_deleted_at" ON "public"."stack_resources" ("deleted_at");
+-- Create "azure_integrations" table
+CREATE TABLE "public"."azure_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "azure_client_id" text NULL,
+ "azure_subscription_id" text NULL,
+ "azure_tenant_id" text NULL,
+ "acr_token_name" text NULL,
+ "acr_resource_group_name" text NULL,
+ "acr_name" text NULL,
+ "service_principal_secret" bytea NULL,
+ "acr_password1" bytea NULL,
+ "acr_password2" bytea NULL,
+ "aks_password" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_azure_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_azure_integrations_deleted_at" to table: "azure_integrations"
+CREATE INDEX "idx_azure_integrations_deleted_at" ON "public"."azure_integrations" ("deleted_at");
+-- Create "stack_source_configs" table
+CREATE TABLE "public"."stack_source_configs" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "stack_revision_id" bigint NULL,
+ "name" text NULL,
+ "display_name" text NULL,
+ "uid" text NULL,
+ "image_repo_uri" text NULL,
+ "image_tag" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_stack_revisions_source_configs" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_source_configs_deleted_at" to table: "stack_source_configs"
+CREATE INDEX "idx_stack_source_configs_deleted_at" ON "public"."stack_source_configs" ("deleted_at");
+-- Create "aws_assume_role_chains" table
+CREATE TABLE "public"."aws_assume_role_chains" (
+ "id" uuid NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "source_arn" text NULL,
+ "target_arn" text NULL,
+ "external_id" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key1" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key1" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key2" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key2" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key3" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key3" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key4" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key4" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "idx_aws_assume_role_chains_deleted_at" to table: "aws_assume_role_chains"
+CREATE INDEX "idx_aws_assume_role_chains_deleted_at" ON "public"."aws_assume_role_chains" ("deleted_at");
+-- Create "clusters" table
+CREATE TABLE "public"."clusters" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "auth_mechanism" text NULL,
+ "project_id" bigint NULL,
+ "agent_integration_enabled" boolean NULL,
+ "name" text NULL,
+ "vanity_name" text NULL,
+ "server" text NULL,
+ "cluster_location_of_origin" text NULL,
+ "tls_server_name" text NULL,
+ "insecure_skip_tls_verify" boolean NULL,
+ "proxy_url" text NULL,
+ "user_location_of_origin" text NULL,
+ "user_impersonate" text NULL,
+ "user_impersonate_groups" text NULL,
+ "infra_id" bigint NULL,
+ "notifications_disabled" boolean NULL,
+ "preview_envs_enabled" boolean NULL,
+ "aws_cluster_id" text NULL,
+ "status" text NULL,
+ "provisioned_by" text NULL,
+ "cloud_provider" text NULL,
+ "cloud_provider_credential_identifier" text NULL,
+ "kube_integration_id" bigint NULL,
+ "o_id_c_integration_id" bigint NULL,
+ "gcp_integration_id" bigint NULL,
+ "aws_integration_id" bigint NULL,
+ "do_integration_id" bigint NULL,
+ "azure_integration_id" bigint NULL,
+ "token_cache_id" bigint NULL,
+ "certificate_authority_data" bytea NULL,
+ "monitor_helm_releases" boolean NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_clusters" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_clusters_deleted_at" to table: "clusters"
+CREATE INDEX "idx_clusters_deleted_at" ON "public"."clusters" ("deleted_at");
+-- Create "gcp_integrations" table
+CREATE TABLE "public"."gcp_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "gcp_project_id" text NULL,
+ "gcpsa_email" text NULL,
+ "g_cpuser_email" text NULL,
+ "gcp_region" text NULL,
+ "gcp_key_data" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_gcp_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_gcp_integrations_deleted_at" to table: "gcp_integrations"
+CREATE INDEX "idx_gcp_integrations_deleted_at" ON "public"."gcp_integrations" ("deleted_at");
+-- Create "invites" table
+CREATE TABLE "public"."invites" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "token" text NULL,
+ "expiry" timestamptz NULL,
+ "email" text NULL,
+ "kind" text NULL,
+ "project_id" bigint NULL,
+ "user_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_invites" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_invites_deleted_at" to table: "invites"
+CREATE INDEX "idx_invites_deleted_at" ON "public"."invites" ("deleted_at");
+-- Create index "invites_token_key" to table: "invites"
+CREATE UNIQUE INDEX "invites_token_key" ON "public"."invites" ("token");
+-- Create "roles" table
+CREATE TABLE "public"."roles" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "kind" text NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_roles" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_roles_deleted_at" to table: "roles"
+CREATE INDEX "idx_roles_deleted_at" ON "public"."roles" ("deleted_at");
+-- Create "basic_integrations" table
+CREATE TABLE "public"."basic_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "user_id" bigint NULL,
+ "project_id" bigint NULL,
+ "username" bytea NULL,
+ "password" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_basic_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_basic_integrations_deleted_at" to table: "basic_integrations"
+CREATE INDEX "idx_basic_integrations_deleted_at" ON "public"."basic_integrations" ("deleted_at");
+-- Create "databases" table
+CREATE TABLE "public"."databases" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "cluster_id" bigint NULL,
+ "infra_id" bigint NULL,
+ "instance_id" text NULL,
+ "instance_endpoint" text NULL,
+ "instance_name" text NULL,
+ "status" text NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_infras_database" FOREIGN KEY ("infra_id") REFERENCES "public"."infras" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT "fk_projects_databases" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_databases_deleted_at" to table: "databases"
+CREATE INDEX "idx_databases_deleted_at" ON "public"."databases" ("deleted_at");
+-- Create "gitlab_integrations" table
+CREATE TABLE "public"."gitlab_integrations" (
+ "id" bigserial NOT NULL,
+ "created_at" timestamptz NULL,
+ "updated_at" timestamptz NULL,
+ "deleted_at" timestamptz NULL,
+ "project_id" bigint NULL,
+ "instance_url" text NULL,
+ "app_client_id" bytea NULL,
+ "app_client_secret" bytea NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_gitlab_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_gitlab_integrations_deleted_at" to table: "gitlab_integrations"
+CREATE INDEX "idx_gitlab_integrations_deleted_at" ON "public"."gitlab_integrations" ("deleted_at");

+ 11 - 0
database/migrations/20230503225844.sql

@@ -0,0 +1,11 @@
+-- Create "porter_app_revisions" table
+CREATE TABLE "public"."porter_app_revisions" (
+ "id" uuid NOT NULL,
+ "created_at" timestamptz NOT NULL DEFAULT now(),
+ "updated_at" timestamptz NOT NULL DEFAULT now(),
+ "deleted_at" timestamptz NULL,
+ "base64_contract" text NOT NULL DEFAULT '',
+ "project_id" bigint NOT NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "fk_projects_porter_app_revisions" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);

+ 3 - 0
database/migrations/atlas.sum

@@ -0,0 +1,3 @@
+h1:1Prq7B4NJp9Ixr6w4PdL7ErT7eXQXnuvuj7wazWzZXc=
+20230503225831.sql h1:ntlMDx/Ml+ylAtHcmLuV+wUccRyDFuuaFBHa7lifA8w=
+20230503225844.sql h1:BGsX0yPz2dpRWClsh72Mczy0/khzfb77UVtWN+GUElA=

+ 1167 - 0
database/schema.sql

@@ -0,0 +1,1167 @@
+-- Create "job_notification_configs" table
+CREATE TABLE "public"."job_notification_configs" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "name" text NULL,
+  "namespace" text NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "last_notified_time" timestamptz NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_job_notification_configs_deleted_at" to table: "job_notification_configs"
+CREATE INDEX "idx_job_notification_configs_deleted_at" ON "public"."job_notification_configs" ("deleted_at");
+-- Create "api_contract_revisions" table
+CREATE TABLE "public"."api_contract_revisions" (
+  "id" uuid NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "base64_contract" text NULL,
+  "cluster_id" bigint NULL,
+  "project_id" bigint NULL,
+  "condition" text NULL,
+  "condition_metadata" jsonb NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_api_contract_revisions_deleted_at" to table: "api_contract_revisions"
+CREATE INDEX "idx_api_contract_revisions_deleted_at" ON "public"."api_contract_revisions" ("deleted_at");
+-- Create "api_tokens" table
+CREATE TABLE "public"."api_tokens" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "unique_id" text NULL,
+  "project_id" bigint NULL,
+  "created_by_user_id" bigint NULL,
+  "expiry" timestamptz NULL,
+  "revoked" boolean NULL,
+  "policy_uid" text NULL,
+  "policy_name" text NULL,
+  "name" text NULL,
+  "secret_key" bytea NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "api_tokens_unique_id_key" to table: "api_tokens"
+CREATE UNIQUE INDEX "api_tokens_unique_id_key" ON "public"."api_tokens" ("unique_id");
+-- Create index "idx_api_tokens_deleted_at" to table: "api_tokens"
+CREATE INDEX "idx_api_tokens_deleted_at" ON "public"."api_tokens" ("deleted_at");
+-- Create "auth_codes" table
+CREATE TABLE "public"."auth_codes" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "token" text NULL,
+  "authorization_code" text NULL,
+  "expiry" timestamptz NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "auth_codes_authorization_code_key" to table: "auth_codes"
+CREATE UNIQUE INDEX "auth_codes_authorization_code_key" ON "public"."auth_codes" ("authorization_code");
+-- Create index "auth_codes_token_key" to table: "auth_codes"
+CREATE UNIQUE INDEX "auth_codes_token_key" ON "public"."auth_codes" ("token");
+-- Create index "idx_auth_codes_deleted_at" to table: "auth_codes"
+CREATE INDEX "idx_auth_codes_deleted_at" ON "public"."auth_codes" ("deleted_at");
+-- Create "users" table
+CREATE TABLE "public"."users" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "email" text NULL,
+  "password" text NULL,
+  "email_verified" boolean NULL,
+  "first_name" text NULL,
+  "last_name" text NULL,
+  "company_name" text NULL,
+  "github_app_integration_id" bigint NULL,
+  "github_user_id" bigint NULL,
+  "google_user_id" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_users_deleted_at" to table: "users"
+CREATE INDEX "idx_users_deleted_at" ON "public"."users" ("deleted_at");
+-- Create index "users_email_key" to table: "users"
+CREATE UNIQUE INDEX "users_email_key" ON "public"."users" ("email");
+-- Create "user_billings" table
+CREATE TABLE "public"."user_billings" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "user_id" bigint NULL,
+  "teammate_id" text NULL,
+  "token" bytea NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_user_billings_deleted_at" to table: "user_billings"
+CREATE INDEX "idx_user_billings_deleted_at" ON "public"."user_billings" ("deleted_at");
+-- Create "token_caches" table
+CREATE TABLE "public"."token_caches" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "expiry" timestamptz NULL,
+  "token" bytea NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_token_caches_deleted_at" to table: "token_caches"
+CREATE INDEX "idx_token_caches_deleted_at" ON "public"."token_caches" ("deleted_at");
+-- Create "slack_integrations" table
+CREATE TABLE "public"."slack_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "client_id" bytea NULL,
+  "access_token" bytea NULL,
+  "refresh_token" bytea NULL,
+  "expiry" timestamptz NULL,
+  "client" text NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "team_id" text NULL,
+  "team_name" text NULL,
+  "team_icon_url" text NULL,
+  "channel" text NULL,
+  "channel_id" text NULL,
+  "configuration_url" text NULL,
+  "webhook" bytea NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_slack_integrations_deleted_at" to table: "slack_integrations"
+CREATE INDEX "idx_slack_integrations_deleted_at" ON "public"."slack_integrations" ("deleted_at");
+-- Create "build_configs" table
+CREATE TABLE "public"."build_configs" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "name" text NULL,
+  "builder" text NULL,
+  "buildpacks" text NULL,
+  "config" bytea NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_build_configs_deleted_at" to table: "build_configs"
+CREATE INDEX "idx_build_configs_deleted_at" ON "public"."build_configs" ("deleted_at");
+-- Create "sessions" table
+CREATE TABLE "public"."sessions" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "key" text NULL,
+  "data" bytea NULL,
+  "expires_at" timestamptz NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_sessions_deleted_at" to table: "sessions"
+CREATE INDEX "idx_sessions_deleted_at" ON "public"."sessions" ("deleted_at");
+-- Create index "sessions_key_key" to table: "sessions"
+CREATE UNIQUE INDEX "sessions_key_key" ON "public"."sessions" ("key");
+-- Create "pw_reset_tokens" table
+CREATE TABLE "public"."pw_reset_tokens" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "email" text NULL,
+  "is_valid" boolean NULL,
+  "expiry" timestamptz NULL,
+  "token" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_pw_reset_tokens_deleted_at" to table: "pw_reset_tokens"
+CREATE INDEX "idx_pw_reset_tokens_deleted_at" ON "public"."pw_reset_tokens" ("deleted_at");
+-- Create "cluster_token_caches" table
+CREATE TABLE "public"."cluster_token_caches" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "expiry" timestamptz NULL,
+  "token" bytea NULL,
+  "cluster_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_cluster_token_caches_deleted_at" to table: "cluster_token_caches"
+CREATE INDEX "idx_cluster_token_caches_deleted_at" ON "public"."cluster_token_caches" ("deleted_at");
+-- Create "projects" table
+CREATE TABLE "public"."projects" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "name" text NULL,
+  "project_usage_id" bigint NULL,
+  "project_usage_cache_id" bigint NULL,
+  "preview_envs_enabled" boolean NULL,
+  "rds_databases_enabled" boolean NULL,
+  "managed_infra_enabled" boolean NULL,
+  "stacks_enabled" boolean NULL,
+  "api_tokens_enabled" boolean NULL,
+  "capi_provisioner_enabled" boolean NULL,
+  "simplified_view_enabled" boolean NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_projects_deleted_at" to table: "projects"
+CREATE INDEX "idx_projects_deleted_at" ON "public"."projects" ("deleted_at");
+-- Create "credentials_exchange_tokens" table
+CREATE TABLE "public"."credentials_exchange_tokens" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "token" bytea NULL,
+  "expiry" timestamptz NULL,
+  "do_credential_id" bigint NULL,
+  "aws_credential_id" bigint NULL,
+  "gcp_credential_id" bigint NULL,
+  "azure_credential_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_credentials_exchange_tokens_deleted_at" to table: "credentials_exchange_tokens"
+CREATE INDEX "idx_credentials_exchange_tokens_deleted_at" ON "public"."credentials_exchange_tokens" ("deleted_at");
+-- Create "project_usages" table
+CREATE TABLE "public"."project_usages" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "resource_cpu" bigint NULL,
+  "resource_memory" bigint NULL,
+  "clusters" bigint NULL,
+  "users" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_project_usages_deleted_at" to table: "project_usages"
+CREATE INDEX "idx_project_usages_deleted_at" ON "public"."project_usages" ("deleted_at");
+-- Create "db_migrations" table
+CREATE TABLE "public"."db_migrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "version" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_db_migrations_deleted_at" to table: "db_migrations"
+CREATE INDEX "idx_db_migrations_deleted_at" ON "public"."db_migrations" ("deleted_at");
+-- Create "deployments" table
+CREATE TABLE "public"."deployments" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "environment_id" bigint NULL,
+  "namespace" text NULL,
+  "status" text NULL,
+  "subdomain" text NULL,
+  "pull_request_id" bigint NULL,
+  "gh_deployment_id" bigint NULL,
+  "ghpr_comment_id" bigint NULL,
+  "pr_name" text NULL,
+  "repo_name" text NULL,
+  "repo_owner" text NULL,
+  "commit_sha" text NULL,
+  "pr_branch_from" text NULL,
+  "pr_branch_into" text NULL,
+  "last_errors" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_deployments_deleted_at" to table: "deployments"
+CREATE INDEX "idx_deployments_deleted_at" ON "public"."deployments" ("deleted_at");
+-- Create "dns_records" table
+CREATE TABLE "public"."dns_records" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "subdomain_prefix" text NULL,
+  "root_domain" text NULL,
+  "endpoint" text NULL,
+  "hostname" text NULL,
+  "cluster_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "dns_records_subdomain_prefix_key" to table: "dns_records"
+CREATE UNIQUE INDEX "dns_records_subdomain_prefix_key" ON "public"."dns_records" ("subdomain_prefix");
+-- Create index "idx_dns_records_deleted_at" to table: "dns_records"
+CREATE INDEX "idx_dns_records_deleted_at" ON "public"."dns_records" ("deleted_at");
+-- Create "environments" table
+CREATE TABLE "public"."environments" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "git_installation_id" bigint NULL,
+  "git_repo_owner" text NULL,
+  "git_repo_name" text NULL,
+  "git_repo_branches" text NULL,
+  "name" text NULL,
+  "mode" text NULL,
+  "new_comments_disabled" boolean NULL,
+  "namespace_labels" bytea NULL,
+  "namespace_annotations" bytea NULL,
+  "git_deploy_branches" text NULL,
+  "webhook_id" text NULL,
+  "github_webhook_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "environments_webhook_id_key" to table: "environments"
+CREATE UNIQUE INDEX "environments_webhook_id_key" ON "public"."environments" ("webhook_id");
+-- Create index "idx_environments_deleted_at" to table: "environments"
+CREATE INDEX "idx_environments_deleted_at" ON "public"."environments" ("deleted_at");
+-- Create "project_usage_caches" table
+CREATE TABLE "public"."project_usage_caches" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "resource_cpu" bigint NULL,
+  "resource_memory" bigint NULL,
+  "clusters" bigint NULL,
+  "users" bigint NULL,
+  "exceeded" boolean NULL,
+  "exceeded_since" timestamptz NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_project_usage_caches_deleted_at" to table: "project_usage_caches"
+CREATE INDEX "idx_project_usage_caches_deleted_at" ON "public"."project_usage_caches" ("deleted_at");
+-- Create "project_billings" table
+CREATE TABLE "public"."project_billings" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "billing_team_id" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_project_billings_deleted_at" to table: "project_billings"
+CREATE INDEX "idx_project_billings_deleted_at" ON "public"."project_billings" ("deleted_at");
+-- Create "porter_apps" table
+CREATE TABLE "public"."porter_apps" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "name" text NULL,
+  "image_repo_uri" text NULL,
+  "git_repo_id" bigint NULL,
+  "repo_name" text NULL,
+  "git_branch" text NULL,
+  "build_context" text NULL,
+  "builder" text NULL,
+  "buildpacks" text NULL,
+  "dockerfile" text NULL,
+  "pull_request_url" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_porter_apps_deleted_at" to table: "porter_apps"
+CREATE INDEX "idx_porter_apps_deleted_at" ON "public"."porter_apps" ("deleted_at");
+-- Create "policies" table
+CREATE TABLE "public"."policies" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "unique_id" text NULL,
+  "project_id" bigint NULL,
+  "created_by_user_id" bigint NULL,
+  "name" text NULL,
+  "policy_bytes" bytea NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_policies_deleted_at" to table: "policies"
+CREATE INDEX "idx_policies_deleted_at" ON "public"."policies" ("deleted_at");
+-- Create index "policies_unique_id_key" to table: "policies"
+CREATE UNIQUE INDEX "policies_unique_id_key" ON "public"."policies" ("unique_id");
+-- Create "github_app_installations" table
+CREATE TABLE "public"."github_app_installations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "account_id" bigint NULL,
+  "installation_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "github_app_installations_account_id_key" to table: "github_app_installations"
+CREATE UNIQUE INDEX "github_app_installations_account_id_key" ON "public"."github_app_installations" ("account_id");
+-- Create index "idx_github_app_installations_deleted_at" to table: "github_app_installations"
+CREATE INDEX "idx_github_app_installations_deleted_at" ON "public"."github_app_installations" ("deleted_at");
+-- Create "github_app_o_auth_integrations" table
+CREATE TABLE "public"."github_app_o_auth_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "client_id" bytea NULL,
+  "access_token" bytea NULL,
+  "refresh_token" bytea NULL,
+  "expiry" timestamptz NULL,
+  "user_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_github_app_o_auth_integrations_deleted_at" to table: "github_app_o_auth_integrations"
+CREATE INDEX "idx_github_app_o_auth_integrations_deleted_at" ON "public"."github_app_o_auth_integrations" ("deleted_at");
+-- Create "gitlab_app_o_auth_integrations" table
+CREATE TABLE "public"."gitlab_app_o_auth_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "o_auth_integration_id" bigint NULL,
+  "gitlab_integration_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_gitlab_app_o_auth_integrations_deleted_at" to table: "gitlab_app_o_auth_integrations"
+CREATE INDEX "idx_gitlab_app_o_auth_integrations_deleted_at" ON "public"."gitlab_app_o_auth_integrations" ("deleted_at");
+-- Create "onboardings" table
+CREATE TABLE "public"."onboardings" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "current_step" text NULL,
+  "connected_source" text NULL,
+  "skip_registry_connection" boolean NULL,
+  "skip_resource_provision" boolean NULL,
+  "registry_connection_id" bigint NULL,
+  "registry_connection_credential_id" bigint NULL,
+  "registry_connection_provider" text NULL,
+  "registry_infra_id" bigint NULL,
+  "registry_infra_credential_id" bigint NULL,
+  "registry_infra_provider" text NULL,
+  "cluster_infra_id" bigint NULL,
+  "cluster_infra_credential_id" bigint NULL,
+  "cluster_infra_provider" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_onboardings_deleted_at" to table: "onboardings"
+CREATE INDEX "idx_onboardings_deleted_at" ON "public"."onboardings" ("deleted_at");
+-- Create "notification_configs" table
+CREATE TABLE "public"."notification_configs" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "enabled" boolean NULL,
+  "success" boolean NULL,
+  "failure" boolean NULL,
+  "last_notified_time" timestamptz NULL,
+  "notif_limit" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_notification_configs_deleted_at" to table: "notification_configs"
+CREATE INDEX "idx_notification_configs_deleted_at" ON "public"."notification_configs" ("deleted_at");
+-- Create "monitor_test_results" table
+CREATE TABLE "public"."monitor_test_results" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "category" text NULL,
+  "object_id" text NULL,
+  "last_status_change" timestamptz NULL,
+  "last_tested" timestamptz NULL,
+  "last_run_result" text NULL,
+  "last_run_result_enum" bigint NULL,
+  "last_recommender_run_id" text NULL,
+  "archived" boolean NULL,
+  "title" text NULL,
+  "message" text NULL,
+  "severity" text NULL,
+  "severity_enum" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_monitor_test_results_deleted_at" to table: "monitor_test_results"
+CREATE INDEX "idx_monitor_test_results_deleted_at" ON "public"."monitor_test_results" ("deleted_at");
+-- Create "allowlists" table
+CREATE TABLE "public"."allowlists" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "user_email" text NOT NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "allowlists_user_email_key" to table: "allowlists"
+CREATE UNIQUE INDEX "allowlists_user_email_key" ON "public"."allowlists" ("user_email");
+-- Create index "idx_allowlists_deleted_at" to table: "allowlists"
+CREATE INDEX "idx_allowlists_deleted_at" ON "public"."allowlists" ("deleted_at");
+-- Create "invites" table
+CREATE TABLE "public"."invites" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "token" text NULL,
+  "expiry" timestamptz NULL,
+  "email" text NULL,
+  "kind" text NULL,
+  "project_id" bigint NULL,
+  "user_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_invites" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_invites_deleted_at" to table: "invites"
+CREATE INDEX "idx_invites_deleted_at" ON "public"."invites" ("deleted_at");
+-- Create index "invites_token_key" to table: "invites"
+CREATE UNIQUE INDEX "invites_token_key" ON "public"."invites" ("token");
+-- Create "kube_events" table
+CREATE TABLE "public"."kube_events" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "name" text NULL,
+  "resource_type" text NULL,
+  "owner_type" text NULL,
+  "owner_name" text NULL,
+  "namespace" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_kube_events_deleted_at" to table: "kube_events"
+CREATE INDEX "idx_kube_events_deleted_at" ON "public"."kube_events" ("deleted_at");
+-- Create "kube_sub_events" table
+CREATE TABLE "public"."kube_sub_events" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "kube_event_id" bigint NULL,
+  "message" text NULL,
+  "reason" text NULL,
+  "timestamp" timestamptz NULL,
+  "event_type" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_kube_events_sub_events" FOREIGN KEY ("kube_event_id") REFERENCES "public"."kube_events" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_kube_sub_events_deleted_at" to table: "kube_sub_events"
+CREATE INDEX "idx_kube_sub_events_deleted_at" ON "public"."kube_sub_events" ("deleted_at");
+-- Create "infras" table
+CREATE TABLE "public"."infras" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "kind" text NULL,
+  "api_version" text NULL,
+  "source_link" text NULL,
+  "source_version" text NULL,
+  "suffix" text NULL,
+  "project_id" bigint NULL,
+  "created_by_user_id" bigint NULL,
+  "parent_cluster_id" bigint NULL,
+  "status" text NULL,
+  "aws_integration_id" bigint NULL,
+  "azure_integration_id" bigint NULL,
+  "gcp_integration_id" bigint NULL,
+  "do_integration_id" bigint NULL,
+  "database_id" bigint NULL,
+  "last_applied" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_infras" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_infras_deleted_at" to table: "infras"
+CREATE INDEX "idx_infras_deleted_at" ON "public"."infras" ("deleted_at");
+-- Create "operations" table
+CREATE TABLE "public"."operations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "uid" text NULL,
+  "infra_id" bigint NULL,
+  "type" text NULL,
+  "status" text NULL,
+  "errored" boolean NULL,
+  "error" text NULL,
+  "template_version" text NULL,
+  "last_applied" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_infras_operations" FOREIGN KEY ("infra_id") REFERENCES "public"."infras" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_operations_deleted_at" to table: "operations"
+CREATE INDEX "idx_operations_deleted_at" ON "public"."operations" ("deleted_at");
+-- Create index "operations_uid_key" to table: "operations"
+CREATE UNIQUE INDEX "operations_uid_key" ON "public"."operations" ("uid");
+-- Create "stacks" table
+CREATE TABLE "public"."stacks" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "namespace" text NULL,
+  "name" text NULL,
+  "uid" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_stacks_deleted_at" to table: "stacks"
+CREATE INDEX "idx_stacks_deleted_at" ON "public"."stacks" ("deleted_at");
+-- Create index "stacks_uid_key" to table: "stacks"
+CREATE UNIQUE INDEX "stacks_uid_key" ON "public"."stacks" ("uid");
+-- Create "stack_revisions" table
+CREATE TABLE "public"."stack_revisions" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "revision_number" bigint NULL,
+  "stack_id" bigint NULL,
+  "status" text NULL,
+  "reason" text NULL,
+  "message" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_stacks_revisions" FOREIGN KEY ("stack_id") REFERENCES "public"."stacks" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_revisions_deleted_at" to table: "stack_revisions"
+CREATE INDEX "idx_stack_revisions_deleted_at" ON "public"."stack_revisions" ("deleted_at");
+-- Create "azure_integrations" table
+CREATE TABLE "public"."azure_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "azure_client_id" text NULL,
+  "azure_subscription_id" text NULL,
+  "azure_tenant_id" text NULL,
+  "acr_token_name" text NULL,
+  "acr_resource_group_name" text NULL,
+  "acr_name" text NULL,
+  "service_principal_secret" bytea NULL,
+  "acr_password1" bytea NULL,
+  "acr_password2" bytea NULL,
+  "aks_password" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_azure_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_azure_integrations_deleted_at" to table: "azure_integrations"
+CREATE INDEX "idx_azure_integrations_deleted_at" ON "public"."azure_integrations" ("deleted_at");
+-- Create "databases" table
+CREATE TABLE "public"."databases" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "infra_id" bigint NULL,
+  "instance_id" text NULL,
+  "instance_endpoint" text NULL,
+  "instance_name" text NULL,
+  "status" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_infras_database" FOREIGN KEY ("infra_id") REFERENCES "public"."infras" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
+  CONSTRAINT "fk_projects_databases" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_databases_deleted_at" to table: "databases"
+CREATE INDEX "idx_databases_deleted_at" ON "public"."databases" ("deleted_at");
+-- Create "gitlab_integrations" table
+CREATE TABLE "public"."gitlab_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "instance_url" text NULL,
+  "app_client_id" bytea NULL,
+  "app_client_secret" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_gitlab_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_gitlab_integrations_deleted_at" to table: "gitlab_integrations"
+CREATE INDEX "idx_gitlab_integrations_deleted_at" ON "public"."gitlab_integrations" ("deleted_at");
+-- Create "aws_integrations" table
+CREATE TABLE "public"."aws_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "aws_arn" text NULL,
+  "aws_region" text NULL,
+  "aws_assume_role_arn" text NULL,
+  "aws_cluster_id" bytea NULL,
+  "aws_access_key_id" bytea NULL,
+  "aws_secret_access_key" bytea NULL,
+  "aws_session_token" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_aws_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_aws_integrations_deleted_at" to table: "aws_integrations"
+CREATE INDEX "idx_aws_integrations_deleted_at" ON "public"."aws_integrations" ("deleted_at");
+-- Create "basic_integrations" table
+CREATE TABLE "public"."basic_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "username" bytea NULL,
+  "password" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_basic_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_basic_integrations_deleted_at" to table: "basic_integrations"
+CREATE INDEX "idx_basic_integrations_deleted_at" ON "public"."basic_integrations" ("deleted_at");
+-- Create "clusters" table
+CREATE TABLE "public"."clusters" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "auth_mechanism" text NULL,
+  "project_id" bigint NULL,
+  "agent_integration_enabled" boolean NULL,
+  "name" text NULL,
+  "vanity_name" text NULL,
+  "server" text NULL,
+  "cluster_location_of_origin" text NULL,
+  "tls_server_name" text NULL,
+  "insecure_skip_tls_verify" boolean NULL,
+  "proxy_url" text NULL,
+  "user_location_of_origin" text NULL,
+  "user_impersonate" text NULL,
+  "user_impersonate_groups" text NULL,
+  "infra_id" bigint NULL,
+  "notifications_disabled" boolean NULL,
+  "preview_envs_enabled" boolean NULL,
+  "aws_cluster_id" text NULL,
+  "status" text NULL,
+  "provisioned_by" text NULL,
+  "cloud_provider" text NULL,
+  "cloud_provider_credential_identifier" text NULL,
+  "kube_integration_id" bigint NULL,
+  "o_id_c_integration_id" bigint NULL,
+  "gcp_integration_id" bigint NULL,
+  "aws_integration_id" bigint NULL,
+  "do_integration_id" bigint NULL,
+  "azure_integration_id" bigint NULL,
+  "token_cache_id" bigint NULL,
+  "certificate_authority_data" bytea NULL,
+  "monitor_helm_releases" boolean NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_clusters" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_clusters_deleted_at" to table: "clusters"
+CREATE INDEX "idx_clusters_deleted_at" ON "public"."clusters" ("deleted_at");
+-- Create "o_auth_integrations" table
+CREATE TABLE "public"."o_auth_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "client_id" bytea NULL,
+  "access_token" bytea NULL,
+  "refresh_token" bytea NULL,
+  "expiry" timestamptz NULL,
+  "client" text NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "target_email" text NULL,
+  "target_name" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_o_auth_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_o_auth_integrations_deleted_at" to table: "o_auth_integrations"
+CREATE INDEX "idx_o_auth_integrations_deleted_at" ON "public"."o_auth_integrations" ("deleted_at");
+-- Create "registries" table
+CREATE TABLE "public"."registries" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "name" text NULL,
+  "url" text NULL,
+  "project_id" bigint NULL,
+  "infra_id" bigint NULL,
+  "gcp_integration_id" bigint NULL,
+  "aws_integration_id" bigint NULL,
+  "azure_integration_id" bigint NULL,
+  "do_integration_id" bigint NULL,
+  "basic_integration_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_registries" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_registries_deleted_at" to table: "registries"
+CREATE INDEX "idx_registries_deleted_at" ON "public"."registries" ("deleted_at");
+-- Create "releases" table
+CREATE TABLE "public"."releases" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "webhook_token" text NULL,
+  "cluster_id" bigint NULL,
+  "project_id" bigint NULL,
+  "name" text NULL,
+  "namespace" text NULL,
+  "stack_resource_id" bigint NULL,
+  "image_repo_uri" text NULL,
+  "event_container" bigint NULL,
+  "notification_config" bigint NULL,
+  "build_config" bigint NULL,
+  "canonical_name" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_releases_deleted_at" to table: "releases"
+CREATE INDEX "idx_releases_deleted_at" ON "public"."releases" ("deleted_at");
+-- Create index "releases_webhook_token_key" to table: "releases"
+CREATE UNIQUE INDEX "releases_webhook_token_key" ON "public"."releases" ("webhook_token");
+-- Create "git_action_configs" table
+CREATE TABLE "public"."git_action_configs" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "release_id" bigint NULL,
+  "git_repo" text NULL,
+  "git_branch" text NULL,
+  "image_repo_uri" text NULL,
+  "github_installation_id" bigint NULL,
+  "git_repo_id" bigint NULL,
+  "gitlab_integration_id" bigint NULL,
+  "dockerfile_path" text NULL,
+  "folder_path" text NULL,
+  "is_installation" boolean NULL,
+  "version" text NULL DEFAULT 'v0.0.1',
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_releases_git_action_config" FOREIGN KEY ("release_id") REFERENCES "public"."releases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_git_action_configs_deleted_at" to table: "git_action_configs"
+CREATE INDEX "idx_git_action_configs_deleted_at" ON "public"."git_action_configs" ("deleted_at");
+-- Create "git_repos" table
+CREATE TABLE "public"."git_repos" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "repo_entity" text NULL,
+  "o_auth_integration_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_git_repos" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_git_repos_deleted_at" to table: "git_repos"
+CREATE INDEX "idx_git_repos_deleted_at" ON "public"."git_repos" ("deleted_at");
+-- Create "helm_repos" table
+CREATE TABLE "public"."helm_repos" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "name" text NULL,
+  "project_id" bigint NULL,
+  "repo_url" text NULL,
+  "basic_auth_integration_id" bigint NULL,
+  "gcp_integration_id" bigint NULL,
+  "aws_integration_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_helm_repos" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_helm_repos_deleted_at" to table: "helm_repos"
+CREATE INDEX "idx_helm_repos_deleted_at" ON "public"."helm_repos" ("deleted_at");
+-- Create "event_containers" table
+CREATE TABLE "public"."event_containers" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "release_id" bigint NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_event_containers_deleted_at" to table: "event_containers"
+CREATE INDEX "idx_event_containers_deleted_at" ON "public"."event_containers" ("deleted_at");
+-- Create "sub_events" table
+CREATE TABLE "public"."sub_events" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "event_container_id" bigint NULL,
+  "event_id" text NULL,
+  "name" text NULL,
+  "index" bigint NULL,
+  "status" bigint NULL,
+  "info" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_event_containers_steps" FOREIGN KEY ("event_container_id") REFERENCES "public"."event_containers" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_sub_events_deleted_at" to table: "sub_events"
+CREATE INDEX "idx_sub_events_deleted_at" ON "public"."sub_events" ("deleted_at");
+-- Create "cluster_candidates" table
+CREATE TABLE "public"."cluster_candidates" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "auth_mechanism" text NULL,
+  "project_id" bigint NULL,
+  "created_cluster_id" bigint NULL,
+  "name" text NULL,
+  "server" text NULL,
+  "context_name" text NULL,
+  "aws_cluster_id_guess" bytea NULL,
+  "kubeconfig" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_cluster_candidates" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_cluster_candidates_deleted_at" to table: "cluster_candidates"
+CREATE INDEX "idx_cluster_candidates_deleted_at" ON "public"."cluster_candidates" ("deleted_at");
+-- Create "cluster_resolvers" table
+CREATE TABLE "public"."cluster_resolvers" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "cluster_candidate_id" bigint NULL,
+  "name" text NULL,
+  "resolved" boolean NULL,
+  "data" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_cluster_candidates_resolvers" FOREIGN KEY ("cluster_candidate_id") REFERENCES "public"."cluster_candidates" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_cluster_resolvers_deleted_at" to table: "cluster_resolvers"
+CREATE INDEX "idx_cluster_resolvers_deleted_at" ON "public"."cluster_resolvers" ("deleted_at");
+-- Create "gcp_integrations" table
+CREATE TABLE "public"."gcp_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "gcp_project_id" text NULL,
+  "gcpsa_email" text NULL,
+  "g_cpuser_email" text NULL,
+  "gcp_region" text NULL,
+  "gcp_key_data" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_gcp_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_gcp_integrations_deleted_at" to table: "gcp_integrations"
+CREATE INDEX "idx_gcp_integrations_deleted_at" ON "public"."gcp_integrations" ("deleted_at");
+-- Create "helm_repo_token_caches" table
+CREATE TABLE "public"."helm_repo_token_caches" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "expiry" timestamptz NULL,
+  "token" bytea NULL,
+  "helm_repo_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_helm_repos_token_cache" FOREIGN KEY ("helm_repo_id") REFERENCES "public"."helm_repos" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_helm_repo_token_caches_deleted_at" to table: "helm_repo_token_caches"
+CREATE INDEX "idx_helm_repo_token_caches_deleted_at" ON "public"."helm_repo_token_caches" ("deleted_at");
+-- Create "stack_source_configs" table
+CREATE TABLE "public"."stack_source_configs" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "stack_revision_id" bigint NULL,
+  "name" text NULL,
+  "display_name" text NULL,
+  "uid" text NULL,
+  "image_repo_uri" text NULL,
+  "image_tag" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_stack_revisions_source_configs" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_source_configs_deleted_at" to table: "stack_source_configs"
+CREATE INDEX "idx_stack_source_configs_deleted_at" ON "public"."stack_source_configs" ("deleted_at");
+-- Create "aws_assume_role_chains" table
+CREATE TABLE "public"."aws_assume_role_chains" (
+  "id" uuid NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "source_arn" text NULL,
+  "target_arn" text NULL,
+  "external_id" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key1" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key1" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key2" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key2" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key3" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key3" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key4" to table: "aws_assume_role_chains"
+CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key4" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
+-- Create index "idx_aws_assume_role_chains_deleted_at" to table: "aws_assume_role_chains"
+CREATE INDEX "idx_aws_assume_role_chains_deleted_at" ON "public"."aws_assume_role_chains" ("deleted_at");
+-- Create "tags" table
+CREATE TABLE "public"."tags" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "project_id" bigint NULL,
+  "name" text NULL,
+  "color" text NULL,
+  PRIMARY KEY ("id")
+);
+-- Create index "idx_tags_deleted_at" to table: "tags"
+CREATE INDEX "idx_tags_deleted_at" ON "public"."tags" ("deleted_at");
+-- Create "release_tags" table
+CREATE TABLE "public"."release_tags" (
+  "tag_id" bigint NOT NULL,
+  "release_id" bigint NOT NULL,
+  PRIMARY KEY ("tag_id", "release_id"),
+  CONSTRAINT "fk_release_tags_release" FOREIGN KEY ("release_id") REFERENCES "public"."releases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
+  CONSTRAINT "fk_release_tags_tag" FOREIGN KEY ("tag_id") REFERENCES "public"."tags" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create "roles" table
+CREATE TABLE "public"."roles" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "kind" text NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_roles" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_roles_deleted_at" to table: "roles"
+CREATE INDEX "idx_roles_deleted_at" ON "public"."roles" ("deleted_at");
+-- Create "stack_env_groups" table
+CREATE TABLE "public"."stack_env_groups" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "stack_revision_id" bigint NULL,
+  "name" text NULL,
+  "namespace" text NULL,
+  "project_id" bigint NULL,
+  "cluster_id" bigint NULL,
+  "uid" text NULL,
+  "env_group_version" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_stack_revisions_env_groups" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_env_groups_deleted_at" to table: "stack_env_groups"
+CREATE INDEX "idx_stack_env_groups_deleted_at" ON "public"."stack_env_groups" ("deleted_at");
+-- Create "o_id_c_integrations" table
+CREATE TABLE "public"."o_id_c_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "client" text NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "issuer_url" bytea NULL,
+  "client_id" bytea NULL,
+  "client_secret" bytea NULL,
+  "certificate_authority_data" bytea NULL,
+  "id_token" bytea NULL,
+  "refresh_token" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_o_id_c_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_o_id_c_integrations_deleted_at" to table: "o_id_c_integrations"
+CREATE INDEX "idx_o_id_c_integrations_deleted_at" ON "public"."o_id_c_integrations" ("deleted_at");
+-- Create "reg_token_caches" table
+CREATE TABLE "public"."reg_token_caches" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "expiry" timestamptz NULL,
+  "token" bytea NULL,
+  "registry_id" bigint NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_registries_token_cache" FOREIGN KEY ("registry_id") REFERENCES "public"."registries" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_reg_token_caches_deleted_at" to table: "reg_token_caches"
+CREATE INDEX "idx_reg_token_caches_deleted_at" ON "public"."reg_token_caches" ("deleted_at");
+-- Create "kube_integrations" table
+CREATE TABLE "public"."kube_integrations" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "mechanism" text NULL,
+  "user_id" bigint NULL,
+  "project_id" bigint NULL,
+  "client_certificate_data" bytea NULL,
+  "client_key_data" bytea NULL,
+  "token" bytea NULL,
+  "username" bytea NULL,
+  "password" bytea NULL,
+  "kubeconfig" bytea NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_projects_kube_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_kube_integrations_deleted_at" to table: "kube_integrations"
+CREATE INDEX "idx_kube_integrations_deleted_at" ON "public"."kube_integrations" ("deleted_at");
+-- Create "stack_resources" table
+CREATE TABLE "public"."stack_resources" (
+  "id" bigserial NOT NULL,
+  "created_at" timestamptz NULL,
+  "updated_at" timestamptz NULL,
+  "deleted_at" timestamptz NULL,
+  "name" text NULL,
+  "uid" text NULL,
+  "stack_revision_id" bigint NULL,
+  "stack_source_config_uid" text NULL,
+  "helm_revision_id" bigint NULL,
+  "values" bytea NULL,
+  "template_repo_url" text NULL,
+  "template_name" text NULL,
+  "template_version" text NULL,
+  PRIMARY KEY ("id"),
+  CONSTRAINT "fk_stack_revisions_resources" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);
+-- Create index "idx_stack_resources_deleted_at" to table: "stack_resources"
+CREATE INDEX "idx_stack_resources_deleted_at" ON "public"."stack_resources" ("deleted_at");
+
+
+-- Create "porter_app_revisions" table
+CREATE TABLE "public"."porter_app_revisions" (
+ "id" uuid NOT NULL,
+ "created_at" timestamptz NOT NULL DEFAULT NOW(),
+ "updated_at" timestamptz NOT NULL DEFAULT NOW(),
+ "deleted_at" timestamptz NULL,
+ "base64_contract" text NOT NULL DEFAULT '',
+ "project_id" bigint NOT NULL,
+ PRIMARY KEY ("id"), 
+ CONSTRAINT "fk_projects_porter_app_revisions" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
+);

+ 9 - 0
database/sql_queries/porter_app_revisions.sql

@@ -0,0 +1,9 @@
+-- name: PorterAppRevisionsForProject :many
+SELECT * FROM porter_app_revisions
+WHERE project_id = $1 AND deleted_at IS NULL;
+
+-- name: CreatePorterAppRevision :one
+INSERT INTO porter_app_revisions 
+(project_id, base64_contract) 
+VALUES 
+($1, $2) RETURNING *;

+ 9 - 0
database/sqlc.yaml

@@ -0,0 +1,9 @@
+version: "2"
+sql:
+  - engine: "postgresql"
+    queries: "sql_queries"
+    schema: "schema.sql"
+    gen:
+      go:
+        package: "queries"
+        out: "generated/queries"

+ 1 - 0
go.mod

@@ -77,6 +77,7 @@ require (
 	github.com/porter-dev/api-contracts v0.0.60
 	github.com/santhosh-tekuri/jsonschema/v5 v5.0.1
 	github.com/stefanmcshane/helm v0.0.0-20221213002717-88a4a2c6e77d
+	github.com/tabbed/pqtype v0.1.1
 	github.com/xanzy/go-gitlab v0.68.0
 	go.uber.org/goleak v1.1.12
 	gopkg.in/segmentio/analytics-go.v3 v3.1.0

+ 2 - 0
go.sum

@@ -1684,6 +1684,8 @@ github.com/sylvia7788/contextcheck v1.0.4/go.mod h1:vuPKJMQ7MQ91ZTqfdyreNKwZjyUg
 github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
 github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
+github.com/tabbed/pqtype v0.1.1 h1:PhEcb9JZ8jr7SUjJDFjRPxny0M8fkXZrxn/a9yQfoZg=
+github.com/tabbed/pqtype v0.1.1/go.mod h1:HLt2kLJPcUhODQkYn3mJkMHXVsuv3Z2n5NZEeKXL0Uk=
 github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
 github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes=
 github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=