Files
njts-accounting-core/backend/sql/fix_existing_data.sql
2026-01-16 09:50:21 +09:00

26 lines
1.1 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 既存の修正仕訳データを修正
-- 1. ID 80のis_deletedをfalseに設定修正版は削除されていないはず
UPDATE journal_entries
SET is_deleted = false
WHERE journal_entry_id = 80;
-- 2. 最新の修正仕訳【修正後】【修正後】などのparent_entry_idが正しく設定されているか確認
-- まず確認クエリ
SELECT journal_entry_id, description, parent_entry_id, is_deleted
FROM journal_entries
WHERE description LIKE '%遠達ビル%'
ORDER BY journal_entry_id;
-- 3. 修正チェーンを正しく設定
-- ID 98: [逆仕訳] 【修正後】·遠達ビル 事務所費用 → parent_entry_idを80に設定
UPDATE journal_entries SET parent_entry_id = 80 WHERE journal_entry_id = 98;
-- ID 99: 【修正後】【修正後】·遠達ビル 事務所費用 → parent_entry_idを98に設定
UPDATE journal_entries SET parent_entry_id = 98 WHERE journal_entry_id = 99;
-- 4. すべての【修正後】仕訳のis_deletedをfalseに設定
UPDATE journal_entries
SET is_deleted = false
WHERE description LIKE '【修正後】%';