-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathspanner.tf
58 lines (57 loc) · 1.84 KB
/
spanner.tf
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
48
49
50
51
52
53
54
55
56
57
58
resource "google_spanner_instance" "npc-chat" {
name = "npc-chat"
display_name = "Data behind npc-chat-api"
config = "regional-us-central1"
autoscaling_config {
autoscaling_limits {
max_processing_units = 10000
min_processing_units = 1000
}
autoscaling_targets {
high_priority_cpu_utilization_percent = 75
storage_utilization_percent = 90
}
}
}
resource "google_spanner_database" "npc-chat" {
instance = google_spanner_instance.npc-chat.name
name = "npc-chat"
version_retention_period = "3d"
ddl = [<<-EOT
CREATE TABLE EntityHistoryBase (
EntityId INT64,
IsWorldData bool,
EventId INT64,
EntityName STRING(MAX),
EntityType INT64,
EventDescription STRING(MAX),
EventDescriptionEmbedding ARRAY<FLOAT64>,
) PRIMARY KEY(EntityId, IsWorldData, EventId)
EOT
, <<-EOT
CREATE TABLE EntityHistoryDynamic (
EntityId INT64,
EventTime TIMESTAMP OPTIONS (
allow_commit_timestamp = true
),
MessageId INT64,
EntityName STRING(MAX),
EntityType INT64,
TargetEntityId INT64,
TargetEntityName STRING(MAX),
EventDescription STRING(MAX),
EventDescriptionEmbedding ARRAY<FLOAT64>,
) PRIMARY KEY(EntityId, EventTime DESC, MessageId DESC)
EOT
, <<-EOT
CREATE INDEX EntityHistoryDynamicByEntityAndTarget
ON EntityHistoryDynamic(EntityId, TargetEntityId, EventTime DESC, MessageId DESC)
STORING (EntityName, TargetEntityName, EventDescription, EventDescriptionEmbedding)
EOT
, <<-EOT
CREATE INDEX EntityHistoryDynamicByTarget
ON EntityHistoryDynamic(TargetEntityId, EventTime DESC, MessageId DESC)
STORING (EntityName, TargetEntityName, EventDescription, EventDescriptionEmbedding)
EOT
]
}