feat: Add ent-based sqlite3 storage
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
46
storage/ent/schema/offlinesession.go
Normal file
46
storage/ent/schema/offlinesession.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
/* Original SQL table:
|
||||
create table offline_session
|
||||
(
|
||||
user_id text not null,
|
||||
conn_id text not null,
|
||||
refresh blob not null,
|
||||
connector_data blob,
|
||||
primary key (user_id, conn_id)
|
||||
);
|
||||
*/
|
||||
|
||||
// OfflineSession holds the schema definition for the OfflineSession entity.
|
||||
type OfflineSession struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the OfflineSession.
|
||||
func (OfflineSession) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
// Using id field here because it's impossible to create multi-key primary yet
|
||||
field.Text("id").
|
||||
SchemaType(textSchema).
|
||||
NotEmpty().
|
||||
Unique(),
|
||||
field.Text("user_id").
|
||||
SchemaType(textSchema).
|
||||
NotEmpty(),
|
||||
field.Text("conn_id").
|
||||
SchemaType(textSchema).
|
||||
NotEmpty(),
|
||||
field.Bytes("refresh"),
|
||||
field.Bytes("connector_data").Nillable().Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the OfflineSession.
|
||||
func (OfflineSession) Edges() []ent.Edge {
|
||||
return []ent.Edge{}
|
||||
}
|
Reference in New Issue
Block a user