Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Add support for execution of multiple statements in one migration file #276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

syndbg
Copy link

@syndbg syndbg commented Sep 15, 2017

@mattes Just something that prevented us from using migrate initially.

@syndbg
Copy link
Author

syndbg commented Sep 15, 2017

Note that I'll take a look at the failing tests and add/modify as needed.

@syndbg syndbg changed the title Add Cassandra Enhancements [WIP] Add Cassandra Enhancements Sep 15, 2017
username = u.User.Username()
password, _ = u.User.Password()
} else {
username = "cassandra"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this default coming from?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the default username/password when enabling PasswordAuthentication authenticator in Cassandra. See https://docs.datastax.com/en/cassandra/2.1/cassandra/security/security_config_native_authenticate_t.html.

@mattes
Copy link
Owner

mattes commented Sep 15, 2017

Thanks for your PR. I think the tests are failing somewhere else actually. Need to investigate as well.

if err := p.session.Query(query).Exec(); err != nil {
// TODO: cast to Cassandra error and get line number
return database.Error{OrigErr: err, Err: "migration failed", Query: migr}
matches := regexp.MustCompile(`(?m:;$)`).Split(query, -1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't execute multiple queries before?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just submitted #280 (but didn't know about this PR until now) which has an opt-in when it comes to multi-statement support to avoid the case of

INSERT INTO codesamples(code) VALUES ('import a;
import b;');

Might be worth considering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unfortunately not.

@mattes
Copy link
Owner

mattes commented Sep 18, 2017

@JensRantil thanks for your PRs. I closed #280 in favor of this one. I'd much rather find a regex than introducing custom query markup. (Partially related: FAQ:why-two-separate-files)

@syndbg and @JensRantil thanks for bringing this up.

@JensRantil
Copy link
Contributor

Any progress on how to handle strings with newlines? We are considering forking migrate internally and using #280 because of this.

@syndbg
Copy link
Author

syndbg commented Nov 15, 2017

@JensRantil I totally slept on this PR. Give me a day and I'll finally address everything left.

@syndbg syndbg changed the title [WIP] Add Cassandra Enhancements Add support for execution of multiple statements in one migration file Nov 15, 2017
Wasn't able to run them locally due to `gocql` not able to connect at all.
Instead, force Cassandra container to broadcast to localhost and auth with default credentials.
@syndbg
Copy link
Author

syndbg commented Nov 15, 2017

@JensRantil @mattes Updated and cleaned up. Cassandra tests still fail and I can't figure out. (note that they were failing before the changes too)

I had troubles getting them running locally, but I got this working eventually. Still I can't find why they're considered a FAIL.

if err := p.session.Query(query).Exec(); err != nil {
// TODO: cast to Cassandra error and get line number
return database.Error{OrigErr: err, Err: "migration failed", Query: migr}
matches := regexp.MustCompile(`(?m:;$)`).Split(query, -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a few unit tests to make sure that this works as expected?

Copy link
Author

@syndbg syndbg Nov 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had troubles getting them running locally, but I got this working eventually. Still I can't find why they're considered a FAIL.

Atm the tests fail for me even before the changes.

I'll spend more time to see why they're failing before I start to add more tests (that are probably going to fail either way).

@emcfarlane
Copy link

Any updates on merging this in?

"time"
nurl "net/url"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use gofmt.

@syndbg
Copy link
Author

syndbg commented Apr 2, 2018

@afking It's quite stale. It was ready to merge in November 2017. Idk about now, it's probably obsolete/out-dated.

@emcfarlane
Copy link

@syndbg thanks, i've applied the changes locally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants