Skip to content

Commit 021c98c

Browse files
cam-aStorj Robot
authored andcommitted
satellite/satellitedb: create table account_freeze_events
create table for account freeze events github issue: #5396 Change-Id: Ia4f93ce5caacd02b161853e3261d237bc715f23d
1 parent 5d727be commit 021c98c

File tree

7 files changed

+1005
-12
lines changed

7 files changed

+1005
-12
lines changed

satellite/satellitedb/dbx/satellitedb.dbx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// dbx.v1 golang satellitedb.dbx .
22

3+
//-- Account Freeze Events --//
4+
model account_freeze_event (
5+
key user_id event
6+
7+
field user_id blob
8+
field event int // enum indicating the type of event
9+
field limits json ( nullable )
10+
field created_at timestamp ( default current_timestamp )
11+
)
12+
313
//-- Node Events --//
414
model node_event (
515
key id

satellite/satellitedb/dbx/satellitedb.dbx.go

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,14 @@ func newpgx(db *DB) *pgxDB {
320320
}
321321

322322
func (obj *pgxDB) Schema() string {
323-
return `CREATE TABLE accounting_rollups (
323+
return `CREATE TABLE account_freeze_events (
324+
user_id bytea NOT NULL,
325+
event integer NOT NULL,
326+
limits jsonb,
327+
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
328+
PRIMARY KEY ( user_id, event )
329+
);
330+
CREATE TABLE accounting_rollups (
324331
node_id bytea NOT NULL,
325332
start_time timestamp with time zone NOT NULL,
326333
put_total bigint NOT NULL,
@@ -1037,7 +1044,14 @@ func newpgxcockroach(db *DB) *pgxcockroachDB {
10371044
}
10381045

10391046
func (obj *pgxcockroachDB) Schema() string {
1040-
return `CREATE TABLE accounting_rollups (
1047+
return `CREATE TABLE account_freeze_events (
1048+
user_id bytea NOT NULL,
1049+
event integer NOT NULL,
1050+
limits jsonb,
1051+
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
1052+
PRIMARY KEY ( user_id, event )
1053+
);
1054+
CREATE TABLE accounting_rollups (
10411055
node_id bytea NOT NULL,
10421056
start_time timestamp with time zone NOT NULL,
10431057
put_total bigint NOT NULL,
@@ -1718,6 +1732,112 @@ nextval:
17181732
fmt.Fprint(f, "]")
17191733
}
17201734

1735+
type AccountFreezeEvent struct {
1736+
UserId []byte
1737+
Event int
1738+
Limits []byte
1739+
CreatedAt time.Time
1740+
}
1741+
1742+
func (AccountFreezeEvent) _Table() string { return "account_freeze_events" }
1743+
1744+
type AccountFreezeEvent_Create_Fields struct {
1745+
Limits AccountFreezeEvent_Limits_Field
1746+
CreatedAt AccountFreezeEvent_CreatedAt_Field
1747+
}
1748+
1749+
type AccountFreezeEvent_Update_Fields struct {
1750+
}
1751+
1752+
type AccountFreezeEvent_UserId_Field struct {
1753+
_set bool
1754+
_null bool
1755+
_value []byte
1756+
}
1757+
1758+
func AccountFreezeEvent_UserId(v []byte) AccountFreezeEvent_UserId_Field {
1759+
return AccountFreezeEvent_UserId_Field{_set: true, _value: v}
1760+
}
1761+
1762+
func (f AccountFreezeEvent_UserId_Field) value() interface{} {
1763+
if !f._set || f._null {
1764+
return nil
1765+
}
1766+
return f._value
1767+
}
1768+
1769+
func (AccountFreezeEvent_UserId_Field) _Column() string { return "user_id" }
1770+
1771+
type AccountFreezeEvent_Event_Field struct {
1772+
_set bool
1773+
_null bool
1774+
_value int
1775+
}
1776+
1777+
func AccountFreezeEvent_Event(v int) AccountFreezeEvent_Event_Field {
1778+
return AccountFreezeEvent_Event_Field{_set: true, _value: v}
1779+
}
1780+
1781+
func (f AccountFreezeEvent_Event_Field) value() interface{} {
1782+
if !f._set || f._null {
1783+
return nil
1784+
}
1785+
return f._value
1786+
}
1787+
1788+
func (AccountFreezeEvent_Event_Field) _Column() string { return "event" }
1789+
1790+
type AccountFreezeEvent_Limits_Field struct {
1791+
_set bool
1792+
_null bool
1793+
_value []byte
1794+
}
1795+
1796+
func AccountFreezeEvent_Limits(v []byte) AccountFreezeEvent_Limits_Field {
1797+
return AccountFreezeEvent_Limits_Field{_set: true, _value: v}
1798+
}
1799+
1800+
func AccountFreezeEvent_Limits_Raw(v []byte) AccountFreezeEvent_Limits_Field {
1801+
if v == nil {
1802+
return AccountFreezeEvent_Limits_Null()
1803+
}
1804+
return AccountFreezeEvent_Limits(v)
1805+
}
1806+
1807+
func AccountFreezeEvent_Limits_Null() AccountFreezeEvent_Limits_Field {
1808+
return AccountFreezeEvent_Limits_Field{_set: true, _null: true}
1809+
}
1810+
1811+
func (f AccountFreezeEvent_Limits_Field) isnull() bool { return !f._set || f._null || f._value == nil }
1812+
1813+
func (f AccountFreezeEvent_Limits_Field) value() interface{} {
1814+
if !f._set || f._null {
1815+
return nil
1816+
}
1817+
return f._value
1818+
}
1819+
1820+
func (AccountFreezeEvent_Limits_Field) _Column() string { return "limits" }
1821+
1822+
type AccountFreezeEvent_CreatedAt_Field struct {
1823+
_set bool
1824+
_null bool
1825+
_value time.Time
1826+
}
1827+
1828+
func AccountFreezeEvent_CreatedAt(v time.Time) AccountFreezeEvent_CreatedAt_Field {
1829+
return AccountFreezeEvent_CreatedAt_Field{_set: true, _value: v}
1830+
}
1831+
1832+
func (f AccountFreezeEvent_CreatedAt_Field) value() interface{} {
1833+
if !f._set || f._null {
1834+
return nil
1835+
}
1836+
return f._value
1837+
}
1838+
1839+
func (AccountFreezeEvent_CreatedAt_Field) _Column() string { return "created_at" }
1840+
17211841
type AccountingRollup struct {
17221842
NodeId []byte
17231843
StartTime time.Time
@@ -20549,6 +20669,16 @@ func (obj *pgxImpl) deleteAll(ctx context.Context) (count int64, err error) {
2054920669
return 0, obj.makeErr(err)
2055020670
}
2055120671

20672+
__count, err = __res.RowsAffected()
20673+
if err != nil {
20674+
return 0, obj.makeErr(err)
20675+
}
20676+
count += __count
20677+
__res, err = obj.driver.ExecContext(ctx, "DELETE FROM account_freeze_events;")
20678+
if err != nil {
20679+
return 0, obj.makeErr(err)
20680+
}
20681+
2055220682
__count, err = __res.RowsAffected()
2055320683
if err != nil {
2055420684
return 0, obj.makeErr(err)
@@ -28399,6 +28529,16 @@ func (obj *pgxcockroachImpl) deleteAll(ctx context.Context) (count int64, err er
2839928529
return 0, obj.makeErr(err)
2840028530
}
2840128531

28532+
__count, err = __res.RowsAffected()
28533+
if err != nil {
28534+
return 0, obj.makeErr(err)
28535+
}
28536+
count += __count
28537+
__res, err = obj.driver.ExecContext(ctx, "DELETE FROM account_freeze_events;")
28538+
if err != nil {
28539+
return 0, obj.makeErr(err)
28540+
}
28541+
2840228542
__count, err = __res.RowsAffected()
2840328543
if err != nil {
2840428544
return 0, obj.makeErr(err)

satellite/satellitedb/dbx/satellitedb.dbx.pgx.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
-- AUTOGENERATED BY storj.io/dbx
22
-- DO NOT EDIT
3+
CREATE TABLE account_freeze_events (
4+
user_id bytea NOT NULL,
5+
event integer NOT NULL,
6+
limits jsonb,
7+
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
8+
PRIMARY KEY ( user_id, event )
9+
);
310
CREATE TABLE accounting_rollups (
411
node_id bytea NOT NULL,
512
start_time timestamp with time zone NOT NULL,

satellite/satellitedb/dbx/satellitedb.dbx.pgxcockroach.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
-- AUTOGENERATED BY storj.io/dbx
22
-- DO NOT EDIT
3+
CREATE TABLE account_freeze_events (
4+
user_id bytea NOT NULL,
5+
event integer NOT NULL,
6+
limits jsonb,
7+
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
8+
PRIMARY KEY ( user_id, event )
9+
);
310
CREATE TABLE accounting_rollups (
411
node_id bytea NOT NULL,
512
start_time timestamp with time zone NOT NULL,

satellite/satellitedb/migrate.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,20 @@ func (db *satelliteDB) PostgresMigration() *migrate.Migration {
21732173
`ALTER TABLE node_events ADD COLUMN last_attempted timestamp with time zone;`,
21742174
},
21752175
},
2176+
{
2177+
DB: &db.migrationDB,
2178+
Description: "Create account_freeze_events table",
2179+
Version: 219,
2180+
Action: migrate.SQL{
2181+
`CREATE TABLE account_freeze_events (
2182+
user_id bytea NOT NULL,
2183+
event integer NOT NULL,
2184+
limits jsonb,
2185+
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
2186+
PRIMARY KEY ( user_id, event )
2187+
);`,
2188+
},
2189+
},
21762190
// NB: after updating testdata in `testdata`, run
21772191
// `go generate` to update `migratez.go`.
21782192
},

satellite/satellitedb/migratez.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ func (db *satelliteDB) testMigration() *migrate.Migration {
1313
{
1414
DB: &db.migrationDB,
1515
Description: "Testing setup",
16-
Version: 218,
16+
Version: 219,
1717
Action: migrate.SQL{`-- AUTOGENERATED BY storj.io/dbx
1818
-- DO NOT EDIT
19+
CREATE TABLE account_freeze_events (
20+
user_id bytea NOT NULL,
21+
event integer NOT NULL,
22+
limits jsonb,
23+
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
24+
PRIMARY KEY ( user_id, event )
25+
);
1926
CREATE TABLE accounting_rollups (
2027
node_id bytea NOT NULL,
2128
start_time timestamp with time zone NOT NULL,
@@ -344,14 +351,6 @@ CREATE TABLE reset_password_tokens (
344351
PRIMARY KEY ( secret ),
345352
UNIQUE ( owner_id )
346353
);
347-
CREATE TABLE verification_audits (
348-
inserted_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
349-
stream_id bytea NOT NULL,
350-
position bigint NOT NULL,
351-
expires_at timestamp with time zone,
352-
encrypted_size integer NOT NULL,
353-
PRIMARY KEY ( inserted_at, stream_id, position )
354-
);
355354
CREATE TABLE reverification_audits (
356355
node_id bytea NOT NULL,
357356
stream_id bytea NOT NULL,
@@ -535,6 +534,14 @@ CREATE TABLE value_attributions (
535534
last_updated timestamp with time zone NOT NULL,
536535
PRIMARY KEY ( project_id, bucket_name )
537536
);
537+
CREATE TABLE verification_audits (
538+
inserted_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
539+
stream_id bytea NOT NULL,
540+
position bigint NOT NULL,
541+
expires_at timestamp with time zone,
542+
encrypted_size integer NOT NULL,
543+
PRIMARY KEY ( inserted_at, stream_id, position )
544+
);
538545
CREATE TABLE webapp_sessions (
539546
id bytea NOT NULL,
540547
user_id bytea NOT NULL,
@@ -615,7 +622,7 @@ CREATE INDEX node_last_ip ON nodes ( last_net ) ;
615622
CREATE INDEX nodes_dis_unk_off_exit_fin_last_success_index ON nodes ( disqualified, unknown_audit_suspended, offline_suspended, exit_finished_at, last_contact_success ) ;
616623
CREATE INDEX nodes_type_last_cont_success_free_disk_ma_mi_patch_vetted_partial_index ON nodes ( type, last_contact_success, free_disk, major, minor, patch, vetted_at ) WHERE nodes.disqualified is NULL AND nodes.unknown_audit_suspended is NULL AND nodes.exit_initiated_at is NULL AND nodes.release = true AND nodes.last_net != '' ;
617624
CREATE INDEX nodes_dis_unk_aud_exit_init_rel_type_last_cont_success_stored_index ON nodes ( disqualified, unknown_audit_suspended, exit_initiated_at, release, type, last_contact_success ) WHERE nodes.disqualified is NULL AND nodes.unknown_audit_suspended is NULL AND nodes.exit_initiated_at is NULL AND nodes.release = true ;
618-
CREATE INDEX node_events_email_event_created_at_index ON node_events ( email, event, created_at ) WHERE node_events.email_sent IS NULL ;
625+
CREATE INDEX node_events_email_event_created_at_index ON node_events ( email, event, created_at ) WHERE node_events.email_sent is NULL ;
619626
CREATE INDEX oauth_clients_user_id_index ON oauth_clients ( user_id ) ;
620627
CREATE INDEX oauth_codes_user_id_index ON oauth_codes ( user_id ) ;
621628
CREATE INDEX oauth_codes_client_id_index ON oauth_codes ( client_id ) ;

0 commit comments

Comments
 (0)