File: mysql2pgsql.sh

package info (click to toggle)
libpreludedb 5.2.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,232 kB
  • sloc: ansic: 29,652; cpp: 16,567; sh: 12,736; sql: 1,436; python: 449; makefile: 291; yacc: 227; lex: 106; xml: 36
file content (21 lines) | stat: -rwxr-xr-x 846 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
sed \
	-e 's/#.*//' \
	-e 's/ INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT/ SERIAL PRIMARY KEY/' \
	-e 's/BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT/BIGSERIAL PRIMARY KEY/' \
	-e 's/BLOB/BYTEA/' \
        -e 's/ TINYINT UNSIGNED / INT2 /g' \
        -e 's/ TINYINT / INT2 /g' \
        -e 's/ SMALLINT UNSIGNED / INT4 /g' \
        -e 's/ SMALLINT / INT2 /g' \
	-e 's/ BIGINT UNSIGNED / INT8 /g' \
	-e 's/ BIGINT / INT8 /g' \
	-e 's/ INT\(EGER\)\{0,1\} UNSIGNED / INT8 /g' \
	-e 's/ INT\(EGER\)\{0,1\} / INT4 /g' \
	-e 's/DATETIME/TIMESTAMP/' \
	-e 's/ENGINE=InnoDB//' \
	-e "s/\"\([^\"]*\)\"/'\1'/g" \
	-e 's/\_parent_type ENUM(\(.*\))/_parent_type VARCHAR(1) CHECK \(_parent_type IN \(\1\)\)/' \
	-e 's/\(.*\) ENUM(\(.*\))/\1 VARCHAR(32) CHECK \(\1 IN \(\2\)\)/' \
	-e 's/\([[:lower:]_]\{1,\}\)([0-9]\{1,\})/\1/g' \
	$1