2020-12-31 03:37:32 +05:30
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
2021-03-24 12:07:51 +05:30
|
|
|
"entgo.io/ent"
|
|
|
|
"entgo.io/ent/schema/field"
|
2020-12-31 03:37:32 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
/* 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(),
|
2021-09-13 19:18:02 +05:30
|
|
|
field.Time("expiry").
|
|
|
|
SchemaType(timeSchema),
|
|
|
|
field.Time("last_request").
|
|
|
|
SchemaType(timeSchema),
|
2020-12-31 03:37:32 +05:30
|
|
|
field.Int("poll_interval"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edges of the DeviceToken.
|
|
|
|
func (DeviceToken) Edges() []ent.Edge {
|
|
|
|
return []ent.Edge{}
|
|
|
|
}
|