I’m not sure which category to put this question in so please move if this isn’t the best place.
I just updated to 2025.1 from 2024.4 today. I’m getting an error on DB migration failure (using postgres):
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "schema_changes_pkey"
DETAIL: Key (change_id)=(2) already exists.
[SQL: INSERT INTO schema_changes (schema_version, changed) VALUES (%(schema_version)s, %(changed)s) RETURNING schema_changes.change_id]
[parameters: {'schema_version': 43, 'changed': datetime.datetime(2025, 1, 27, 16, 53, 49, 211120, tzinfo=datetime.timezone.utc)}]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
It’s trying to insert a new record on the schema_changes
table with a change_id
of 2. Here is the current contents of that table:
homeassistant=> select * from schema_changes;
change_id | schema_version | changed
-----------+----------------+-------------------------------
1 | 33 | 2023-08-31 23:50:44.50582-07
2 | 34 | 2024-03-11 06:24:46.002292-07
3 | 35 | 2024-03-11 06:24:46.096434-07
4 | 36 | 2024-03-11 06:24:46.250117-07
5 | 37 | 2024-03-11 06:24:46.261012-07
6 | 38 | 2024-03-11 06:24:46.471125-07
7 | 39 | 2024-03-11 06:24:46.493914-07
8 | 40 | 2024-03-11 06:24:46.505855-07
9 | 41 | 2024-03-11 06:24:46.506798-07
10 | 42 | 2024-03-11 06:24:46.507722-07
(10 rows)
Why is it trying to insert with an ID of 2? And not just entering it at the end of the table with an auto-generated ID of 11?