Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
"""Migration 31: Add image_subfolder column to images table.
This migration adds an image_subfolder column to the images table to support
configurable image subfolder strategies (flat, date, type, hash).
Existing images get an empty string (flat/root directory).
"""
import sqlite3
from invokeai.app.services.shared.sqlite_migrator.sqlite_migrator_common import Migration
class Migration31Callback:
"""Migration to add image_subfolder column to images table."""
def __call__(self, cursor: sqlite3.Cursor) -> None:
self._add_image_subfolder_column(cursor)
def _add_image_subfolder_column(self, cursor: sqlite3.Cursor) -> None:
"""Add image_subfolder column to images table."""
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='images';")
if cursor.fetchone() is None:
return
cursor.execute("PRAGMA table_info(images);")
columns = [row[1] for row in cursor.fetchall()]
if "image_subfolder" not in columns:
cursor.execute("ALTER TABLE images ADD COLUMN image_subfolder TEXT NOT NULL DEFAULT '';")
def build_migration_31() -> Migration:
"""Builds the migration object for migrating from version 30 to version 31.
This migration adds an image_subfolder column to the images table.
"""
return Migration(
id="migration_31",
depends_on="migration_30",
from_version=30,
to_version=31,
callback=Migration31Callback(),
)