Skip to content

Commit

Permalink
fix: device_record index
Browse files Browse the repository at this point in the history
  • Loading branch information
saitofun committed Jul 2, 2024
1 parent 5f383f9 commit bacbb73
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
29 changes: 29 additions & 0 deletions docker-compose-dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "3.6"

services:
mqtt:
image: eclipse-mosquitto:1.6.15
container_name: mosquitto
restart: always
ports:
- "1883:1883"
volumes:
- ./build/mqtt-dep:/mosquitto/data

postgres:
image: postgres:13
restart: always
command:
[
"postgres",
"-cshared_preload_libraries=pg_stat_statements",
"-cstats_temp_directory=/tmp"
]
environment:
POSTGRES_USER: "test"
POSTGRES_PASSWORD: "passwd"
POSTGRES_DB: "pebble"
volumes:
- ./build/postgres-dep:/var/lib/postgresql/data
ports:
- "5432:5432"
14 changes: 6 additions & 8 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,28 @@ services:
ports:
- "1883:1883"
volumes:
- ./build/mqtt:/mosquitto/data
- ./build/mqtt-dev:/mosquitto/data

postgres:
image: postgres:13
restart: always
command:
[
"postgres",
"-cshared_preload_libraries=pg_stat_statements"
"-cshared_preload_libraries=pg_stat_statements",
"-cstats_temp_directory=/tmp"
]
environment:
POSTGRES_USER: "test"
POSTGRES_PASSWORD: "passwd"
POSTGRES_DB: "pebble"
volumes:
- ./build/postgres:/var/lib/postgresql/data
- ./build/postgres-dev:/var/lib/postgresql/data
ports:
- "5432:5432"

pebble-sequencer:
# build:
# context: .
# dockerfile: ./cmd/sequencer/Dockerfile
image: ghcr.io/machinefi/pebble-sequencer:main
image: ghcr.io/machinefi/pebble-sequencer:latest
container_name: pebble-sequencer
platform: linux/amd64
restart: always
Expand All @@ -50,5 +48,5 @@ services:
PEBBLE_SEQUENCER__ProjectVersion: v0.0.1
PEBBLE_SEQUENCER__Blockchain_Network: IOTX_TESTNET
volumes:
- ./build/sequencer:/data
- ./build/tx-dev:/data

5 changes: 3 additions & 2 deletions pkg/models/device_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package models

type DeviceRecord struct {
ID string `gorm:"primary_key"`
Imei string `gorm:"not null"`
Hash string
Imei string `gorm:"index:device_record_imei;not null"`
Operator string `gorm:"not null"`
Snr string `gorm:"not null;type:numeric(10,2);default:0"`
Vbat string `gorm:"not null;type:numeric(10,2);default:0"`
Expand All @@ -17,7 +18,7 @@ type DeviceRecord struct {
Latitude string `gorm:"not null;default:0"`
Longitude string `gorm:"not null;default:0"`
Signature string `gorm:"not null;default:''"`
Timestamp int64 `gorm:"not null;default:0"`
Timestamp int64 `gorm:"index:device_record_timestamp;not null;default:0"`

OperationTimes
}
Expand Down

0 comments on commit bacbb73

Please sign in to comment.