feat: Add ent-based sqlite3 storage

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
m.nabokikh
2020-12-31 02:07:32 +04:00
parent 674631c9ab
commit 11859166d0
31 changed files with 1878 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
package schema
import (
"github.com/facebook/ent"
"github.com/facebook/ent/schema/field"
)
/* Original SQL table:
create table device_token
(
device_code text not null primary key,
status text not null,
token blob,
expiry timestamp not null,
last_request timestamp not null,
poll_interval integer not null
);
*/
// DeviceToken holds the schema definition for the DeviceToken entity.
type DeviceToken struct {
ent.Schema
}
// Fields of the DeviceToken.
func (DeviceToken) Fields() []ent.Field {
return []ent.Field{
field.Text("device_code").
SchemaType(textSchema).
NotEmpty().
Unique(),
field.Text("status").
SchemaType(textSchema).
NotEmpty(),
field.Bytes("token").Nillable().Optional(),
field.Time("expiry"),
field.Time("last_request"),
field.Int("poll_interval"),
}
}
// Edges of the DeviceToken.
func (DeviceToken) Edges() []ent.Edge {
return []ent.Edge{}
}