Skip to content

Commit

Permalink
chore(migrations) split init migration
Browse files Browse the repository at this point in the history
Former-commit-id: 9d9b665a3d5eeb25a0fe87101d2091e534952b1d
  • Loading branch information
thibaultcha committed Aug 20, 2015
1 parent fc95a1c commit 8b7cef1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
48 changes: 21 additions & 27 deletions kong/dao/cassandra/schema/migrations.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
local Migrations = {
-- init schema migration
-- skeleton
{
name = "2015-01-12-175310_init_schema",
init = true,

name = "2015-01-12-175310_skeleton",
up = function(options)
return [[
CREATE KEYSPACE IF NOT EXISTS "]]..options.keyspace..[["
Expand All @@ -15,7 +14,19 @@ local Migrations = {
id text PRIMARY KEY,
migrations list<text>
);
]]
end,
down = function(options)
return [[
DROP KEYSPACE "]]..options.keyspace..[[";
]]
end
},
-- init schema migration
{
name = "2015-01-12-175310_init_schema",
up = function(options)
return [[
CREATE TABLE IF NOT EXISTS consumers(
id uuid,
custom_id text,
Expand All @@ -31,6 +42,8 @@ local Migrations = {
id uuid,
name text,
public_dns text,
path text,
strip_path boolean,
target_url text,
preserve_host boolean,
created_at timestamp,
Expand All @@ -39,6 +52,7 @@ local Migrations = {
CREATE INDEX IF NOT EXISTS ON apis(name);
CREATE INDEX IF NOT EXISTS ON apis(public_dns);
CREATE INDEX IF NOT EXISTS ON apis(path);
CREATE TABLE IF NOT EXISTS plugins_configurations(
id uuid,
Expand All @@ -56,31 +70,11 @@ local Migrations = {
CREATE INDEX IF NOT EXISTS ON plugins_configurations(consumer_id);
]]
end,

down = function(options)
return [[
DROP KEYSPACE "]]..options.keyspace..[[";
]]
end
},

-- 0.3.0
{
name = "2015-05-22-235608_0.3.0",

up = function(options)
return [[
ALTER TABLE apis ADD path text;
ALTER TABLE apis ADD strip_path boolean;
CREATE INDEX IF NOT EXISTS apis_path ON apis(path);
]]
end,

down = function(options)
return [[
DROP INDEX apis_path;
ALTER TABLE apis DROP path;
ALTER TABLE apis DROP strip_path;
DROP TABLE consumers;
DROP TABLE apis;
DROP TABLE plugins_configurations;
]]
end
}
Expand Down
1 change: 0 additions & 1 deletion spec/integration/dao/cassandra/migrations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ local function has_migration(state, arguments)
error(err)
end

local found = false
for _, record in ipairs(rows) do
if record.id == identifier then
for _, migration_record in ipairs(record.migrations) do
Expand Down

0 comments on commit 8b7cef1

Please sign in to comment.