mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(mm): update db schema & migration
This commit is contained in:
parent
94e1e64296
commit
f13f5984c0
@ -103,14 +103,12 @@ class ModelRecordServiceSQL(ModelRecordServiceBase):
|
|||||||
"""--sql
|
"""--sql
|
||||||
INSERT INTO models (
|
INSERT INTO models (
|
||||||
id,
|
id,
|
||||||
hash,
|
|
||||||
config
|
config
|
||||||
)
|
)
|
||||||
VALUES (?,?,?);
|
VALUES (?,?);
|
||||||
""",
|
""",
|
||||||
(
|
(
|
||||||
key,
|
key,
|
||||||
record.hash,
|
|
||||||
json_serialized,
|
json_serialized,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -8,16 +8,13 @@ class Migration7Callback:
|
|||||||
self._create_models_table(cursor)
|
self._create_models_table(cursor)
|
||||||
|
|
||||||
def _create_models_table(self, cursor: sqlite3.Cursor) -> None:
|
def _create_models_table(self, cursor: sqlite3.Cursor) -> None:
|
||||||
"""
|
"""Creates the v4.0.0 models table."""
|
||||||
Adds the timestamp trigger to the model_config table.
|
|
||||||
|
|
||||||
This trigger was inadvertently dropped in earlier migration scripts.
|
|
||||||
"""
|
|
||||||
|
|
||||||
tables = [
|
tables = [
|
||||||
"""--sql
|
"""--sql
|
||||||
CREATE TABLE IF NOT EXISTS models (
|
CREATE TABLE IF NOT EXISTS models (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
|
hash TEXT GENERATED ALWAYS as (json_extract(config, '$.hash')) VIRTUAL NOT NULL,
|
||||||
base TEXT GENERATED ALWAYS as (json_extract(config, '$.base')) VIRTUAL NOT NULL,
|
base TEXT GENERATED ALWAYS as (json_extract(config, '$.base')) VIRTUAL NOT NULL,
|
||||||
type TEXT GENERATED ALWAYS as (json_extract(config, '$.type')) VIRTUAL NOT NULL,
|
type TEXT GENERATED ALWAYS as (json_extract(config, '$.type')) VIRTUAL NOT NULL,
|
||||||
path TEXT GENERATED ALWAYS as (json_extract(config, '$.path')) VIRTUAL NOT NULL,
|
path TEXT GENERATED ALWAYS as (json_extract(config, '$.path')) VIRTUAL NOT NULL,
|
||||||
@ -27,7 +24,6 @@ class Migration7Callback:
|
|||||||
source TEXT GENERATED ALWAYS as (json_extract(config, '$.source')) VIRTUAL NOT NULL,
|
source TEXT GENERATED ALWAYS as (json_extract(config, '$.source')) VIRTUAL NOT NULL,
|
||||||
source_type TEXT GENERATED ALWAYS as (json_extract(config, '$.source_type')) VIRTUAL NOT NULL,
|
source_type TEXT GENERATED ALWAYS as (json_extract(config, '$.source_type')) VIRTUAL NOT NULL,
|
||||||
source_api_response TEXT GENERATED ALWAYS as (json_extract(config, '$.source_api_response')) VIRTUAL,
|
source_api_response TEXT GENERATED ALWAYS as (json_extract(config, '$.source_api_response')) VIRTUAL,
|
||||||
hash TEXT NOT NULL, -- could be null
|
|
||||||
-- Serialized JSON representation of the whole config object, which will contain additional fields from subclasses
|
-- Serialized JSON representation of the whole config object, which will contain additional fields from subclasses
|
||||||
config TEXT NOT NULL,
|
config TEXT NOT NULL,
|
||||||
created_at DATETIME NOT NULL DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')),
|
created_at DATETIME NOT NULL DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')),
|
||||||
@ -66,12 +62,12 @@ class Migration7Callback:
|
|||||||
|
|
||||||
def build_migration_7() -> Migration:
|
def build_migration_7() -> Migration:
|
||||||
"""
|
"""
|
||||||
Build the migration from database version 5 to 6.
|
Build the migration from database version 6 to 7.
|
||||||
|
|
||||||
This migration does the following:
|
This migration does the following:
|
||||||
- Adds the model_config_updated_at trigger if it does not exist
|
- Adds the new models table
|
||||||
- Delete all ip_adapter models so that the model prober can find and
|
- TODO(MM2): Drops the old model_records, model_metadata, model_tags and tags tables.
|
||||||
update with the correct image processor model.
|
- TODO(MM2): Migrates model names and descriptions from `models.yaml` to the new table (?).
|
||||||
"""
|
"""
|
||||||
migration_7 = Migration(
|
migration_7 = Migration(
|
||||||
from_version=6,
|
from_version=6,
|
||||||
|
Loading…
Reference in New Issue
Block a user