-
Notifications
You must be signed in to change notification settings - Fork 0
/
2015-01-12-175310_init_schema.lua
65 lines (53 loc) · 1.59 KB
/
2015-01-12-175310_init_schema.lua
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
59
60
61
62
63
64
65
local Migration = {
name = "2015-01-12-175310_init_schema",
init = true,
up = function(options)
return [[
CREATE KEYSPACE IF NOT EXISTS "]]..options.keyspace..[["
WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};
USE ]]..options.keyspace..[[;
CREATE TABLE IF NOT EXISTS schema_migrations(
id text PRIMARY KEY,
migrations list<text>
);
CREATE TABLE IF NOT EXISTS consumers(
id uuid,
custom_id text,
username text,
created_at timestamp,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS ON consumers(custom_id);
CREATE INDEX IF NOT EXISTS ON consumers(username);
CREATE TABLE IF NOT EXISTS apis(
id uuid,
name text,
public_dns text,
target_url text,
created_at timestamp,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS ON apis(name);
CREATE INDEX IF NOT EXISTS ON apis(public_dns);
CREATE TABLE IF NOT EXISTS plugins_configurations(
id uuid,
api_id uuid,
consumer_id uuid,
name text,
value text, -- serialized plugin data
enabled boolean,
created_at timestamp,
PRIMARY KEY (id, name)
);
CREATE INDEX IF NOT EXISTS ON plugins_configurations(name);
CREATE INDEX IF NOT EXISTS ON plugins_configurations(api_id);
CREATE INDEX IF NOT EXISTS ON plugins_configurations(consumer_id);
]]
end,
down = function(options)
return [[
DROP KEYSPACE ]]..options.keyspace..[[;
]]
end
}
return Migration