Skip to content

Commit

Permalink
fix(c*) do not prepare DDL queries in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Feb 14, 2017
1 parent 2793003 commit 614994a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions kong/dao/db/cassandra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,10 @@ function _M:queries(queries, no_keyspace)
for _, query in ipairs(utils.split(queries, ";")) do
query = utils.strip(query)
if query ~= "" then
local res, err = self:query(query, nil, nil, nil, no_keyspace)
local res, err = self:query(query, nil, {
prepared = false,
--consistency = cassandra.consistencies.all,
}, nil, no_keyspace)
if not res then return err end
end
end
Expand Down Expand Up @@ -542,19 +545,26 @@ function _M:current_migrations()
-- Check if keyspace exists
local rows, err = self:query(q_keyspace_exists, {
self.cluster_options.keyspace
}, {prepared = false}, nil, true)
}, {
prepared = false,
--consistency = cassandra.consistencies.all,
}, nil, true)
if not rows then return nil, err
elseif #rows == 0 then return {} end

-- Check if schema_migrations table exists
rows, err = self:query(q_migrations_table_exists, {
self.cluster_options.keyspace,
"schema_migrations"
}, {prepared = false})
}, {
prepared = false,
--consistency = cassandra.consistencies.all,
})
if not rows then return nil, err
elseif rows[1] and rows[1].count > 0 then
return self:query("SELECT * FROM schema_migrations", nil, {
prepared = false
prepared = false,
--consistency = cassandra.consistencies.all,
})
else return {} end
end
Expand All @@ -564,7 +574,13 @@ function _M:record_migration(id, name)
UPDATE schema_migrations
SET migrations = migrations + ?
WHERE id = ?
]], {cassandra.list({name}), id})
]], {
cassandra.list({ name }),
id
}, {
prepared = false,
--consistency = cassandra.consistencies.all,
})
if not res then return nil, err end
return true
end
Expand Down

0 comments on commit 614994a

Please sign in to comment.