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

Регистронезависимая замена #6

Open
githubniko opened this issue Jan 24, 2024 · 0 comments
Open

Регистронезависимая замена #6

githubniko opened this issue Jan 24, 2024 · 0 comments

Comments

@githubniko
Copy link

githubniko commented Jan 24, 2024

A very good converter, but in order to use it, I had to include a case-independent search for AUTOINCREMENT in sed, because my "sqlite3 database.sqlite .dump" creates a dump in lowercase.

CREATE TABLE "migrations" ("id" integer not null primary key autoincrement, "migration" varchar not null, "batch" integer not null);

Added an "I" at the end.

sed \
-e '/PRAGMA.*;/ d' \
-e '/BEGIN TRANSACTION.*/ d' \
-e '/COMMIT;/ d' \
-e '/.*sqlite_sequence.*;/d' \
-e "s/ varchar/ varchar($VARCHAR)/g" \
-e "s/ integer/ int/g" \
-e 's/"/`/g' \
-e 's/CREATE TABLE \(`\w\+`\)/DROP TABLE IF EXISTS \1;\nCREATE TABLE \1/' \
-e 's/\(CREATE TABLE.*\)\(PRIMARY KEY\) \(AUTOINCREMENT\)\(.*\)\();\)/\1AUTO_INCREMENT\4, PRIMARY KEY(id)\5/I' \
-e "s/'t'/1/g" \
-e "s/'f'/0/g" \
$1
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

No branches or pull requests

1 participant