# A Spring AI 1.x table under the 2.0 repository

A 1.1.x-shaped table (no sequence_id column) holds 2 rows for "old-conv".

2.0.1 repository, findByConversationId("old-conv"):
  ERROR: column "sequence_id" does not exist

Migration: add the column, backfill it from the timestamp order, then make it NOT NULL:
  ALTER TABLE SPRING_AI_CHAT_MEMORY ADD COLUMN sequence_id BIGINT
  UPDATE SPRING_AI_CHAT_MEMORY m SET sequence_id = s.rn FROM (SELECT ctid AS c, row_number() OVER (PARTITION ...
  ALTER TABLE SPRING_AI_CHAT_MEMORY ALTER COLUMN sequence_id SET NOT NULL
  CREATE INDEX IF NOT EXISTS SPRING_AI_CHAT_MEMORY_CONVERSATION_ID_SEQUENCE_ID_IDX ON SPRING_AI_CHAT_MEMORY(c...

findByConversationId("old-conv") after the migration:
  USER      My name is Priya
  ASSISTANT Nice to meet you, Priya.
