Closed sadowskik closed 8 years ago
Good idea. Was thinking of something similar for bulk loads but separating each command with a semi-colon.
Approach with a dedicated stage section allows you to execute many semi-colon separated statements within a single stage:
-- description: created schema
-- authoredAt: 1370023265
-- up:
-- stage: 1
CREATE TABLE events (
batch_id text,
occurred_at uuid,
event_type text,
payload blob,
PRIMARY KEY (batch_id, occurred_at, event_type)
);
DROP TABLE old_events;
--stage: 2
GRANT MODIFY ON events TO test_user
--stage: 3
GRANT SELECT ON events TO test_user
will be executed as:
session.execute("CREATE TABLE events ...; DROP TABLE old_events;")
session.execute("GRANT MODIFY ON...")
session.execute("GRANT SELECT ON...")
Nice
Great, I'd love to see this being merged!
@comeara Any chance that this will get merged?
This has been merged to master and will be released in 2.3.
2.3.0 was released today.
Some of the queries cannot be executed via cassandra driver in a single go. GRANT query is one of the examples. In order to effectively setup some grants the one need to run separate query, for each GRANT:
This pull request introduces the notion of stages. Each migration section (up or down) can be segregated with the
--stage
keyword. Queries defined within each stage are executed in a single go (singlesession.execute(...)
invocation). Example:This migration will be applied by running
session.execute()
three times:session.execute("CREATE TABLE events (...")
session.execute("GRANT MODIFY ON...")
session.execute("GRANT SELECT ON...")