diff --git a/satellite/satellitedb/dbx/project_bucket.dbx b/satellite/satellitedb/dbx/project_bucket.dbx index 2cc63285e..919295bf4 100644 --- a/satellite/satellitedb/dbx/project_bucket.dbx +++ b/satellite/satellitedb/dbx/project_bucket.dbx @@ -148,8 +148,6 @@ model value_attribution ( // unless the user signed up with a specific partner. // note: this field is duplicated in bucket_metainfo.user_agent. field user_agent blob ( updatable, nullable ) - // TODO remove as part of release 1.81 or after - field partner_id blob (nullable, default null) // last_updated is updated whenever the row changes. field last_updated timestamp ( autoinsert, autoupdate ) ) diff --git a/satellite/satellitedb/dbx/satellitedb.dbx.go b/satellite/satellitedb/dbx/satellitedb.dbx.go index 1eeb79261..64552e8b7 100644 --- a/satellite/satellitedb/dbx/satellitedb.dbx.go +++ b/satellite/satellitedb/dbx/satellitedb.dbx.go @@ -798,7 +798,6 @@ CREATE TABLE value_attributions ( project_id bytea NOT NULL, bucket_name bytea NOT NULL, user_agent bytea, - partner_id bytea DEFAULT null, last_updated timestamp with time zone NOT NULL, PRIMARY KEY ( project_id, bucket_name ) ); @@ -1490,7 +1489,6 @@ CREATE TABLE value_attributions ( project_id bytea NOT NULL, bucket_name bytea NOT NULL, user_agent bytea, - partner_id bytea DEFAULT null, last_updated timestamp with time zone NOT NULL, PRIMARY KEY ( project_id, bucket_name ) ); @@ -10459,7 +10457,6 @@ type ValueAttribution struct { ProjectId []byte BucketName []byte UserAgent []byte - PartnerId []byte LastUpdated time.Time } @@ -10467,7 +10464,6 @@ func (ValueAttribution) _Table() string { return "value_attributions" } type ValueAttribution_Create_Fields struct { UserAgent ValueAttribution_UserAgent_Field - PartnerId ValueAttribution_PartnerId_Field } type ValueAttribution_Update_Fields struct { @@ -10544,38 +10540,6 @@ func (f ValueAttribution_UserAgent_Field) value() interface{} { func (ValueAttribution_UserAgent_Field) _Column() string { return "user_agent" } -type ValueAttribution_PartnerId_Field struct { - _set bool - _null bool - _value []byte -} - -func ValueAttribution_PartnerId(v []byte) ValueAttribution_PartnerId_Field { - return ValueAttribution_PartnerId_Field{_set: true, _value: v} -} - -func ValueAttribution_PartnerId_Raw(v []byte) ValueAttribution_PartnerId_Field { - if v == nil { - return ValueAttribution_PartnerId_Null() - } - return ValueAttribution_PartnerId(v) -} - -func ValueAttribution_PartnerId_Null() ValueAttribution_PartnerId_Field { - return ValueAttribution_PartnerId_Field{_set: true, _null: true} -} - -func (f ValueAttribution_PartnerId_Field) isnull() bool { return !f._set || f._null || f._value == nil } - -func (f ValueAttribution_PartnerId_Field) value() interface{} { - if !f._set || f._null { - return nil - } - return f._value -} - -func (ValueAttribution_PartnerId_Field) _Column() string { return "partner_id" } - type ValueAttribution_LastUpdated_Field struct { _set bool _null bool @@ -13187,37 +13151,16 @@ func (obj *pgxImpl) Create_ValueAttribution(ctx context.Context, __user_agent_val := optional.UserAgent.value() __last_updated_val := __now - var __columns = &__sqlbundle_Hole{SQL: __sqlbundle_Literal("project_id, bucket_name, user_agent, last_updated")} - var __placeholders = &__sqlbundle_Hole{SQL: __sqlbundle_Literal("?, ?, ?, ?")} - var __clause = &__sqlbundle_Hole{SQL: __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("("), __columns, __sqlbundle_Literal(") VALUES ("), __placeholders, __sqlbundle_Literal(")")}}} - - var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("INSERT INTO value_attributions "), __clause, __sqlbundle_Literal(" RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.partner_id, value_attributions.last_updated")}} + var __embed_stmt = __sqlbundle_Literal("INSERT INTO value_attributions ( project_id, bucket_name, user_agent, last_updated ) VALUES ( ?, ?, ?, ? ) RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.last_updated") var __values []interface{} __values = append(__values, __project_id_val, __bucket_name_val, __user_agent_val, __last_updated_val) - __optional_columns := __sqlbundle_Literals{Join: ", "} - __optional_placeholders := __sqlbundle_Literals{Join: ", "} - - if optional.PartnerId._set { - __values = append(__values, optional.PartnerId.value()) - __optional_columns.SQLs = append(__optional_columns.SQLs, __sqlbundle_Literal("partner_id")) - __optional_placeholders.SQLs = append(__optional_placeholders.SQLs, __sqlbundle_Literal("?")) - } - - if len(__optional_columns.SQLs) == 0 { - if __columns.SQL == nil { - __clause.SQL = __sqlbundle_Literal("DEFAULT VALUES") - } - } else { - __columns.SQL = __sqlbundle_Literals{Join: ", ", SQLs: []__sqlbundle_SQL{__columns.SQL, __optional_columns}} - __placeholders.SQL = __sqlbundle_Literals{Join: ", ", SQLs: []__sqlbundle_SQL{__placeholders.SQL, __optional_placeholders}} - } var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt) obj.logStmt(__stmt, __values...) value_attribution = &ValueAttribution{} - err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.PartnerId, &value_attribution.LastUpdated) + err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.LastUpdated) if err != nil { return nil, obj.makeErr(err) } @@ -16574,7 +16517,7 @@ func (obj *pgxImpl) Get_ValueAttribution_By_ProjectId_And_BucketName(ctx context value_attribution *ValueAttribution, err error) { defer mon.Task()(&ctx)(&err) - var __embed_stmt = __sqlbundle_Literal("SELECT value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.partner_id, value_attributions.last_updated FROM value_attributions WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ?") + var __embed_stmt = __sqlbundle_Literal("SELECT value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.last_updated FROM value_attributions WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ?") var __values []interface{} __values = append(__values, value_attribution_project_id.value(), value_attribution_bucket_name.value()) @@ -16583,7 +16526,7 @@ func (obj *pgxImpl) Get_ValueAttribution_By_ProjectId_And_BucketName(ctx context obj.logStmt(__stmt, __values...) value_attribution = &ValueAttribution{} - err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.PartnerId, &value_attribution.LastUpdated) + err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.LastUpdated) if err != nil { return (*ValueAttribution)(nil), obj.makeErr(err) } @@ -18823,7 +18766,7 @@ func (obj *pgxImpl) Update_ValueAttribution_By_ProjectId_And_BucketName(ctx cont defer mon.Task()(&ctx)(&err) var __sets = &__sqlbundle_Hole{} - var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE value_attributions SET "), __sets, __sqlbundle_Literal(" WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ? RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.partner_id, value_attributions.last_updated")}} + var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE value_attributions SET "), __sets, __sqlbundle_Literal(" WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ? RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.last_updated")}} __sets_sql := __sqlbundle_Literals{Join: ", "} var __values []interface{} @@ -18848,7 +18791,7 @@ func (obj *pgxImpl) Update_ValueAttribution_By_ProjectId_And_BucketName(ctx cont obj.logStmt(__stmt, __values...) value_attribution = &ValueAttribution{} - err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.PartnerId, &value_attribution.LastUpdated) + err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.LastUpdated) if err == sql.ErrNoRows { return nil, nil } @@ -21345,37 +21288,16 @@ func (obj *pgxcockroachImpl) Create_ValueAttribution(ctx context.Context, __user_agent_val := optional.UserAgent.value() __last_updated_val := __now - var __columns = &__sqlbundle_Hole{SQL: __sqlbundle_Literal("project_id, bucket_name, user_agent, last_updated")} - var __placeholders = &__sqlbundle_Hole{SQL: __sqlbundle_Literal("?, ?, ?, ?")} - var __clause = &__sqlbundle_Hole{SQL: __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("("), __columns, __sqlbundle_Literal(") VALUES ("), __placeholders, __sqlbundle_Literal(")")}}} - - var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("INSERT INTO value_attributions "), __clause, __sqlbundle_Literal(" RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.partner_id, value_attributions.last_updated")}} + var __embed_stmt = __sqlbundle_Literal("INSERT INTO value_attributions ( project_id, bucket_name, user_agent, last_updated ) VALUES ( ?, ?, ?, ? ) RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.last_updated") var __values []interface{} __values = append(__values, __project_id_val, __bucket_name_val, __user_agent_val, __last_updated_val) - __optional_columns := __sqlbundle_Literals{Join: ", "} - __optional_placeholders := __sqlbundle_Literals{Join: ", "} - - if optional.PartnerId._set { - __values = append(__values, optional.PartnerId.value()) - __optional_columns.SQLs = append(__optional_columns.SQLs, __sqlbundle_Literal("partner_id")) - __optional_placeholders.SQLs = append(__optional_placeholders.SQLs, __sqlbundle_Literal("?")) - } - - if len(__optional_columns.SQLs) == 0 { - if __columns.SQL == nil { - __clause.SQL = __sqlbundle_Literal("DEFAULT VALUES") - } - } else { - __columns.SQL = __sqlbundle_Literals{Join: ", ", SQLs: []__sqlbundle_SQL{__columns.SQL, __optional_columns}} - __placeholders.SQL = __sqlbundle_Literals{Join: ", ", SQLs: []__sqlbundle_SQL{__placeholders.SQL, __optional_placeholders}} - } var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt) obj.logStmt(__stmt, __values...) value_attribution = &ValueAttribution{} - err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.PartnerId, &value_attribution.LastUpdated) + err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.LastUpdated) if err != nil { return nil, obj.makeErr(err) } @@ -24732,7 +24654,7 @@ func (obj *pgxcockroachImpl) Get_ValueAttribution_By_ProjectId_And_BucketName(ct value_attribution *ValueAttribution, err error) { defer mon.Task()(&ctx)(&err) - var __embed_stmt = __sqlbundle_Literal("SELECT value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.partner_id, value_attributions.last_updated FROM value_attributions WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ?") + var __embed_stmt = __sqlbundle_Literal("SELECT value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.last_updated FROM value_attributions WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ?") var __values []interface{} __values = append(__values, value_attribution_project_id.value(), value_attribution_bucket_name.value()) @@ -24741,7 +24663,7 @@ func (obj *pgxcockroachImpl) Get_ValueAttribution_By_ProjectId_And_BucketName(ct obj.logStmt(__stmt, __values...) value_attribution = &ValueAttribution{} - err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.PartnerId, &value_attribution.LastUpdated) + err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.LastUpdated) if err != nil { return (*ValueAttribution)(nil), obj.makeErr(err) } @@ -26981,7 +26903,7 @@ func (obj *pgxcockroachImpl) Update_ValueAttribution_By_ProjectId_And_BucketName defer mon.Task()(&ctx)(&err) var __sets = &__sqlbundle_Hole{} - var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE value_attributions SET "), __sets, __sqlbundle_Literal(" WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ? RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.partner_id, value_attributions.last_updated")}} + var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE value_attributions SET "), __sets, __sqlbundle_Literal(" WHERE value_attributions.project_id = ? AND value_attributions.bucket_name = ? RETURNING value_attributions.project_id, value_attributions.bucket_name, value_attributions.user_agent, value_attributions.last_updated")}} __sets_sql := __sqlbundle_Literals{Join: ", "} var __values []interface{} @@ -27006,7 +26928,7 @@ func (obj *pgxcockroachImpl) Update_ValueAttribution_By_ProjectId_And_BucketName obj.logStmt(__stmt, __values...) value_attribution = &ValueAttribution{} - err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.PartnerId, &value_attribution.LastUpdated) + err = obj.queryRowContext(ctx, __stmt, __values...).Scan(&value_attribution.ProjectId, &value_attribution.BucketName, &value_attribution.UserAgent, &value_attribution.LastUpdated) if err == sql.ErrNoRows { return nil, nil } diff --git a/satellite/satellitedb/dbx/satellitedb.dbx.pgx.sql b/satellite/satellitedb/dbx/satellitedb.dbx.pgx.sql index 4e395fbbf..dd12f0681 100644 --- a/satellite/satellitedb/dbx/satellitedb.dbx.pgx.sql +++ b/satellite/satellitedb/dbx/satellitedb.dbx.pgx.sql @@ -485,7 +485,6 @@ CREATE TABLE value_attributions ( project_id bytea NOT NULL, bucket_name bytea NOT NULL, user_agent bytea, - partner_id bytea DEFAULT null, last_updated timestamp with time zone NOT NULL, PRIMARY KEY ( project_id, bucket_name ) ); diff --git a/satellite/satellitedb/dbx/satellitedb.dbx.pgxcockroach.sql b/satellite/satellitedb/dbx/satellitedb.dbx.pgxcockroach.sql index 4e395fbbf..dd12f0681 100644 --- a/satellite/satellitedb/dbx/satellitedb.dbx.pgxcockroach.sql +++ b/satellite/satellitedb/dbx/satellitedb.dbx.pgxcockroach.sql @@ -485,7 +485,6 @@ CREATE TABLE value_attributions ( project_id bytea NOT NULL, bucket_name bytea NOT NULL, user_agent bytea, - partner_id bytea DEFAULT null, last_updated timestamp with time zone NOT NULL, PRIMARY KEY ( project_id, bucket_name ) ); diff --git a/satellite/satellitedb/migrate_test.go b/satellite/satellitedb/migrate_test.go index 26eba0fc2..6c7f44024 100644 --- a/satellite/satellitedb/migrate_test.go +++ b/satellite/satellitedb/migrate_test.go @@ -275,6 +275,12 @@ func migrateTest(t *testing.T, connStr string) { finalSchema = currentSchema } + // TODO(moby): remove this exception on adding migration to remove partner_id column + valueAttributions, ok := finalSchema.FindTable("value_attributions") + if ok { + valueAttributions.RemoveColumn("partner_id") + } + // verify that we also match the dbx version require.Equal(t, dbxschema, finalSchema, "result of all migration scripts did not match dbx schema") }