-- 国宝回归（每件文物一条专属回归路线）+ 南迁北归改名

-- 1) 南迁路线改名为「文物南迁北归之路」
UPDATE narrative_routes SET title = '文物南迁北归之路' WHERE code = 'nanqian';

-- 2) 新增机构：保利艺术博物馆（北京）
INSERT INTO institutions (id, name, short_name, institution_type, country, province, city, address, location, is_verified, publish_status) VALUES
  ('a0000000-0000-0000-0000-000000000031','保利艺术博物馆','保利博物馆','museum','中国','北京市','北京','北京市东城区东直门内大街朝阳门北大街1号新保利大厦',ST_SetSRID(ST_MakePoint(116.4340,39.9380),4326)::geography,true,'published')
ON CONFLICT (id) DO NOTHING;

-- 3) 新增回归国宝文物
DELETE FROM artifact_locations WHERE artifact_id IN (
  'b0000000-0000-0000-0000-000000000084','b0000000-0000-0000-0000-000000000085',
  'b0000000-0000-0000-0000-000000000086','b0000000-0000-0000-0000-000000000087'
);

INSERT INTO artifacts (id,unified_map_id,name,category,dynasty,level,material,current_status,home_institution_id,summary,story_hook,persona_quote,publish_status) VALUES
  ('b0000000-0000-0000-0000-000000000084','CN-2026-000084','圆明园十二生肖兽首·牛首','gold_silver','清代','level_1','铜','at_home','a0000000-0000-0000-0000-000000000031','圆明园海晏堂十二生肖水力钟兽首之一，1860 年英法联军劫掠后流失海外，2000 年由保利集团于香港拍卖竞得回归。','圆明园喷泉上的青铜牛，漂泊一个半世纪后回家','我本是皇家水钟的报时神兽，流落百年终于归来。','published'),
  ('b0000000-0000-0000-0000-000000000085','CN-2026-000085','圆明园十二生肖兽首·马首','gold_silver','清代','level_1','铜','at_home','a0000000-0000-0000-0000-000000000031','圆明园兽首之马首，2007 年现身拍卖，何鸿燊出资购回并于 2019—2020 年捐赠国家，最终回归圆明园。','一尊马首，牵动整个民族的回家之愿','我等了一百六十年，终于又听见了故园的风。','published'),
  ('b0000000-0000-0000-0000-000000000086','CN-2026-000086','青铜虎鎣','bronze','西周','level_1','青铜','at_home','a0000000-0000-0000-0000-000000000002','西周晚期青铜盉，因虎形装饰得名"虎鎣"，1860 年流失英国，2018 年于英国拍卖后由买家捐赠中国，入藏国家博物馆。','一只青铜小虎，跨越重洋回到祖先的土地','我身上的虎纹，记得三千年前的火光。','published'),
  ('b0000000-0000-0000-0000-000000000087','CN-2026-000087','王处直墓彩绘散乐浮雕','stone_carving','五代','level_1','汉白玉','at_home','a0000000-0000-0000-0000-000000000002','五代王处直墓汉白玉彩绘浮雕，1994 年被盗流失海外，2000 年于美国被追索回归，入藏中国国家博物馆。','一面被盗凿走的乐舞墙，从纽约被追回故土','我刻着一支千年的乐队，曾被生生凿下墙壁。','published')
ON CONFLICT (id) DO NOTHING;

UPDATE artifacts SET repatriation_status = 'repatriated'
WHERE id IN (
  'b0000000-0000-0000-0000-000000000010',
  'b0000000-0000-0000-0000-000000000084',
  'b0000000-0000-0000-0000-000000000085',
  'b0000000-0000-0000-0000-000000000086',
  'b0000000-0000-0000-0000-000000000087'
);

INSERT INTO artifact_locations (id,artifact_id,location_type,institution_id,public_location,precision,display_status,source_type,is_current,verified_at) VALUES
  ('c0000000-0000-0000-0000-000000000084','b0000000-0000-0000-0000-000000000084','domestic','a0000000-0000-0000-0000-000000000031',ST_SetSRID(ST_MakePoint(116.4340,39.9380),4326)::geography,'exact_building','on_display','public_source',true,NOW()),
  ('c0000000-0000-0000-0000-000000000085','b0000000-0000-0000-0000-000000000085','domestic','a0000000-0000-0000-0000-000000000031',ST_SetSRID(ST_MakePoint(116.4340,39.9380),4326)::geography,'exact_building','on_display','public_source',true,NOW()),
  ('c0000000-0000-0000-0000-000000000086','b0000000-0000-0000-0000-000000000086','domestic','a0000000-0000-0000-0000-000000000002',ST_SetSRID(ST_MakePoint(116.4074,39.9052),4326)::geography,'exact_building','on_display','public_source',true,NOW()),
  ('c0000000-0000-0000-0000-000000000087','b0000000-0000-0000-0000-000000000087','domestic','a0000000-0000-0000-0000-000000000002',ST_SetSRID(ST_MakePoint(116.4074,39.9052),4326)::geography,'exact_building','on_display','public_source',true,NOW())
ON CONFLICT (id) DO NOTHING;

-- 4) 每件回归国宝的专属路线
DELETE FROM route_stops WHERE route_id IN (
  SELECT id FROM narrative_routes WHERE code IN ('huigui','huigui-mpl','huigui-niushou','huigui-mashou','huigui-huying','huigui-wangchuzhi')
);
DELETE FROM narrative_routes WHERE code IN ('huigui','huigui-mpl','huigui-niushou','huigui-mashou','huigui-huying','huigui-wangchuzhi');

INSERT INTO narrative_routes (id, code, title, type, color, artifact_id, summary) VALUES
  ('d0000000-0000-0000-0000-000000000002','huigui-mpl','皿方罍·完罍归湘','repatriation','#3f9e6a','b0000000-0000-0000-0000-000000000010','器盖与器身分离近一个世纪，2014 年器盖由海外回归，与器身在湖南合体。'),
  ('d0000000-0000-0000-0000-000000000003','huigui-niushou','圆明园牛首·百年归途','repatriation','#3f9e6a','b0000000-0000-0000-0000-000000000084','1860 年流失，2000 年保利于香港竞得回归。'),
  ('d0000000-0000-0000-0000-000000000004','huigui-mashou','圆明园马首·游子归园','repatriation','#3f9e6a','b0000000-0000-0000-0000-000000000085','2007 年购回，2020 年捐赠并回归圆明园。'),
  ('d0000000-0000-0000-0000-000000000005','huigui-huying','青铜虎鎣·虎归东方','repatriation','#3f9e6a','b0000000-0000-0000-0000-000000000086','1860 年流失英国，2018 年捐赠回归国博。'),
  ('d0000000-0000-0000-0000-000000000006','huigui-wangchuzhi','王处直墓浮雕·乐归故里','repatriation','#3f9e6a','b0000000-0000-0000-0000-000000000087','1994 年被盗，2000 年自美国追索回归。')
ON CONFLICT (code) DO NOTHING;

INSERT INTO route_stops (route_id, seq, name, lng, lat, year_label, event) VALUES
  -- 皿方罍
  ('d0000000-0000-0000-0000-000000000002',1,'海外（流失）',2.3376,48.8606,'1920s','器盖流散海外，辗转私人藏家'),
  ('d0000000-0000-0000-0000-000000000002',2,'纽约',-73.9632,40.7794,'2014','现身纽约拍卖，国内紧急斡旋'),
  ('d0000000-0000-0000-0000-000000000002',3,'香港',114.1694,22.3193,'2014','达成洽购，护送入境'),
  ('d0000000-0000-0000-0000-000000000002',4,'北京',116.4074,39.9052,'2014','回归交接'),
  ('d0000000-0000-0000-0000-000000000002',5,'长沙·湖南博物院',112.9838,28.2082,'2014','器身器盖合体，完罍归湘'),
  -- 牛首
  ('d0000000-0000-0000-0000-000000000003',1,'北京·圆明园',116.2980,40.0080,'1860','英法联军劫掠，兽首流失'),
  ('d0000000-0000-0000-0000-000000000003',2,'海外',-0.1276,51.5074,'1860—1999','辗转欧美藏家与拍卖行'),
  ('d0000000-0000-0000-0000-000000000003',3,'香港',114.1694,22.3193,'2000','保利集团拍卖竞得'),
  ('d0000000-0000-0000-0000-000000000003',4,'北京·保利艺术博物馆',116.4340,39.9380,'2000','入藏保利，向公众展出'),
  -- 马首
  ('d0000000-0000-0000-0000-000000000004',1,'北京·圆明园',116.2980,40.0080,'1860','随海晏堂兽首一同流失'),
  ('d0000000-0000-0000-0000-000000000004',2,'海外',114.1694,22.3193,'1860—2006','流散港台与海外'),
  ('d0000000-0000-0000-0000-000000000004',3,'香港',114.1694,22.3193,'2007','何鸿燊出资购回'),
  ('d0000000-0000-0000-0000-000000000004',4,'北京·圆明园',116.2980,40.0080,'2020','捐赠国家，回归圆明园'),
  -- 虎鎣
  ('d0000000-0000-0000-0000-000000000005',1,'北京·圆明园',116.2980,40.0080,'1860','英军劫掠后带往英国'),
  ('d0000000-0000-0000-0000-000000000005',2,'英国·肯特',1.0789,51.2802,'1860—2018','存于英国家族逾一个半世纪'),
  ('d0000000-0000-0000-0000-000000000005',3,'伦敦',-0.1276,51.5074,'2018','现身拍卖，买家捐赠中国'),
  ('d0000000-0000-0000-0000-000000000005',4,'北京·国家博物馆',116.4074,39.9052,'2018','入藏国博'),
  -- 王处直墓浮雕
  ('d0000000-0000-0000-0000-000000000006',1,'河北·曲阳',114.7000,38.6200,'1994','王处直墓被盗，浮雕被凿走'),
  ('d0000000-0000-0000-0000-000000000006',2,'美国',-73.9632,40.7794,'1994—2000','流入美国艺术市场'),
  ('d0000000-0000-0000-0000-000000000006',3,'纽约',-73.9632,40.7794,'2000','中方跨国追索，拍卖叫停'),
  ('d0000000-0000-0000-0000-000000000006',4,'北京·国家博物馆',116.4074,39.9052,'2000','成功回归，入藏国博');
