Skip to content

Mysql alter table #45

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

Merged
merged 5 commits into from
Feb 23, 2025
Merged

Mysql alter table #45

merged 5 commits into from
Feb 23, 2025

Conversation

belchior
Copy link
Owner

@belchior belchior commented Feb 23, 2025

Basic API

use sql_query_builder as sql;

let query = sql::AlterTable::new()
  .alter_table("users")
  .add("column id serial primary key")
  .drop("constraint idx_created_at")
  .rename("column name to full_name")
  .as_string();

let expected = "\
  ALTER TABLE users \
  ADD column id serial primary key, \
  DROP constraint idx_created_at, \
  RENAME column name to full_name\
";

assert_eq!(expected, query);

Output

ALTER TABLE users
  ADD COLUMN id serial primary key,
  DROP CONSTRAINT idx_created_at,
  RENAME COLUMN name to full_name

@belchior belchior self-assigned this Feb 23, 2025
@belchior belchior merged commit 1cef484 into mysql Feb 23, 2025
1 check passed
@belchior belchior added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 23, 2025
@belchior belchior linked an issue Feb 23, 2025 that may be closed by this pull request
@belchior belchior deleted the mysql-alter-table branch March 28, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Add MySQL syntax
1 participant