-
Notifications
You must be signed in to change notification settings - Fork 2
/
sol_test.go
47 lines (40 loc) · 1 KB
/
sol_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package sol
import (
"time"
"github.com/aodin/sol/types"
)
// Valid schemas should not panic
var users = Table("users",
Column("id", types.Integer()),
Column("email", types.Varchar().Limit(256).NotNull()), // TODO unique
Column("name", types.Varchar().Limit(32).NotNull()),
Column("password", types.Varchar()),
Column("created_at", types.Timestamp()),
PrimaryKey("id"),
Unique("email"),
)
var contacts = Table("contacts",
Column("id", types.Integer()),
ForeignKey("user_id", users),
Column("key", types.Varchar()),
Column("value", types.Varchar()),
PrimaryKey("id"),
Unique("user_id", "key"),
)
var messages = Table("messages",
Column("id", types.Integer()),
ForeignKey("user_id", users.C("id")),
SelfForeignKey("parent_id", "id"),
Column("text", types.Text()),
)
type user struct {
ID uint64 `db:",omitempty"`
Email string
Name string
CreatedAt time.Time `db:",omitempty"`
}
type contact struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
Key, Value string
}