作業SQLをさらしてみる
Table "public.char_tbl" Column | Type | Modifiers -----------+-----------------------+-------------------- char_id | character varying(16) | not null char_img | character varying(64) | not null char_name | character varying(32) | char_type | integer | not null default 0 Indexes: "char_tbl_pkey" PRIMARY KEY, btree (char_id, char_type)
Table "public.character_tbl" Column | Type | Modifiers --------------+---------+----------- style_id | integer | not null character_id | integer | not null name | text | not null file | text | not null Indexes: "character_tbl_pkey" PRIMARY KEY, btree (style_id, character_id)
INSERT INTO character_tbl ( style_id , character_id , name , file ) SELECT c.char_type as style_id, (SELECT count(b.char_id) FROM char_tbl b WHERE b.char_id < c.char_id and b.char_type = c.char_type) as character_id, c.char_name as name, c.char_img as file FROM char_tbl c ORDER BY style_id, character_id
新旧のテーブル定義が違ったから
データを移行する為のSQLを書いてデータ移行した。