Skip to content

Commit

Permalink
remove primary key id from record (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcajmagic authored May 10, 2019
1 parent 2a10825 commit 9e8990a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ type Connection struct {
}

type Record struct {
ID int `json:"id"`
Type EventType `json:"type" gorm:"type:int"`
DeviceID string `json:"deviceid"`
BirthDate int64 `json:"birthdate"`
Expand Down
2 changes: 0 additions & 2 deletions db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestGetRecords(t *testing.T) {
deviceID: "1234",
expectedRecords: []Record{
{
ID: 1,
Type: 0,
DeviceID: "1234",
},
Expand Down Expand Up @@ -121,7 +120,6 @@ func TestGetRecordsOfType(t *testing.T) {
eventType: 1,
expectedRecords: []Record{
{
ID: 1,
Type: 1,
DeviceID: "1234",
},
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker-compose/setup_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ SQL="/cockroach/cockroach.sh sql $HOSTPARAMS"
$SQL -e "CREATE USER IF NOT EXISTS roachadmin;"
$SQL -e "CREATE DATABASE IF NOT EXISTS devices;"
$SQL -e "GRANT ALL ON DATABASE devices TO roachadmin;"
$SQL -e "CREATE TABLE devices.events (id BIGINT PRIMARY KEY DEFAULT unique_rowid(), type INT NOT NULL, device_id STRING NOT NULL, birth_date BIGINT NOT NULL, death_date BIGINT NOT NULL, data BYTES NOT NULL, nonce BYTES NOT NULL, alg STRING NOT NULL, kid STRING NOT NULL, INDEX idx_events_id_birth_date (device_id, birth_date DESC), INDEX idx_events_death_date (death_date DESC)) "
$SQL -e "CREATE TABLE devices.events (type INT NOT NULL, device_id STRING NOT NULL, birth_date BIGINT NOT NULL, death_date BIGINT NOT NULL, data BYTES NOT NULL, nonce BYTES NOT NULL, alg STRING NOT NULL, kid STRING NOT NULL, INDEX idx_events_id_birth_date (device_id, birth_date DESC), INDEX idx_events_death_date (death_date DESC)) "
$SQL -e "CREATE TABLE devices.blacklist (id STRING PRIMARY KEY, reason STRING NOT NULL);"

0 comments on commit 9e8990a

Please sign in to comment.