Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseline scripts executed unexpectedly #394

Closed
tianzhou opened this issue Jan 17, 2022 Discussed in #350 · 4 comments · Fixed by #505
Closed

baseline scripts executed unexpectedly #394

tianzhou opened this issue Jan 17, 2022 Discussed in #350 · 4 comments · Fixed by #505
Assignees

Comments

@tianzhou
Copy link
Collaborator

Discussed in #350

Originally posted by NickStepanov January 10, 2022
Hi,

I am trying to test the use of Clickhouse with VCS based workflow.

I am creating a UI based baseline and it works fine.

After that, I am pushing a file to gitlab with my baseline, it get picked up by Bytebase and it even states:

SQL (This is a baseline migration and bytebase won't apply the SQL to the database, it will only record a baseline history)

After that, in the created issue, I try to click run, thinking that it will not touch my db, but I get

execute query ..... Table ...... already exists

It looks like my baseline file is trying to be executed my live db.

Is that an issue? Or am I doing something wrong?

Nik

@tianzhou
Copy link
Collaborator Author

Converted from #350

@tianzhou
Copy link
Collaborator Author

@qsliu2017 please take a look.

To setup a ClickHouse instance, you can follow:

https://bytebase.com/blog/how-to-run-clickhouse-with-docker-and-connect-using-mysql-client

@qsliu2017
Copy link
Contributor

I find that baseline SQL script will always be executed, both UI and Git workflow

截屏2022-01-27 下午5 56 38

In bytebase docs, it says

...This is achieved by using a baseline migration script which includes the entire schema of that live database.
...
Internally, the baseline migration only causes Bytebase to update its migration history table to record the baseline state. It won't apply the SQL statements in that baseline file to the corresponding database since the database is the origin source of the baseline and already has all the schema.

@tianzhou ,I need more info about

  1. does the baseline script need statements?
  2. should the baseline script be executed?

@tianzhou
Copy link
Collaborator Author

I find that baseline SQL script will always be executed, both UI and Git workflow

截屏2022-01-27 下午5 56 38

In bytebase docs, it says

...This is achieved by using a baseline migration script which includes the entire schema of that live database.
...
Internally, the baseline migration only causes Bytebase to update its migration history table to record the baseline state. It won't apply the SQL statements in that baseline file to the corresponding database since the database is the origin source of the baseline and already has all the schema.

@tianzhou ,I need more info about

  1. does the baseline script need statements?
  2. should the baseline script be executed?

What baseline means is it tells Bytebase the current state of schema (aka establishing the baseline)

So Baseline statement does has statement, it's the statement tells Bytebase the current schema.

But it should NOT be executed.

@qsliu2017 qsliu2017 changed the title VCS baseline tries to apply sql to db and fails (Clickhouse) baseline scripts executed unexpectedly Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants