CREATE TABLE `asset_images` (
	`id` text NOT NULL,
	`user_id` text NOT NULL,
	`asset_id` text NOT NULL,
	`image_id` text NOT NULL,
	`sort_order` integer DEFAULT 0 NOT NULL,
	`updated_at` text NOT NULL,
	`deleted_at` text,
	`purged_at` text,
	`version` integer DEFAULT 1 NOT NULL,
	PRIMARY KEY(`id`, `user_id`)
);
--> statement-breakpoint
CREATE INDEX `asset_images_updated_at_idx` ON `asset_images` (`updated_at`);--> statement-breakpoint
CREATE INDEX `asset_images_asset_id_idx` ON `asset_images` (`asset_id`);--> statement-breakpoint
CREATE INDEX `asset_images_user_id_idx` ON `asset_images` (`user_id`);--> statement-breakpoint
CREATE TABLE `asset_persons` (
	`id` text NOT NULL,
	`user_id` text NOT NULL,
	`asset_id` text NOT NULL,
	`person_id` text NOT NULL,
	`updated_at` text NOT NULL,
	`deleted_at` text,
	`purged_at` text,
	`version` integer DEFAULT 1 NOT NULL,
	PRIMARY KEY(`id`, `user_id`)
);
--> statement-breakpoint
CREATE INDEX `asset_persons_updated_at_idx` ON `asset_persons` (`updated_at`);--> statement-breakpoint
CREATE INDEX `asset_persons_asset_id_idx` ON `asset_persons` (`asset_id`);--> statement-breakpoint
CREATE INDEX `asset_persons_user_id_idx` ON `asset_persons` (`user_id`);--> statement-breakpoint
CREATE TABLE `assets` (
	`id` text NOT NULL,
	`user_id` text NOT NULL,
	`room_id` text,
	`title` text NOT NULL,
	`category` text,
	`status` text DEFAULT 'draft' NOT NULL,
	`condition` text,
	`brand` text,
	`model` text,
	`serial_number` text,
	`purchase_price` integer,
	`purchase_year` integer,
	`notes` text,
	`cover_image_id` text,
	`updated_at` text NOT NULL,
	`deleted_at` text,
	`purged_at` text,
	`version` integer DEFAULT 1 NOT NULL,
	PRIMARY KEY(`id`, `user_id`)
);
--> statement-breakpoint
CREATE INDEX `assets_updated_at_idx` ON `assets` (`updated_at`);--> statement-breakpoint
CREATE INDEX `assets_user_id_idx` ON `assets` (`user_id`);--> statement-breakpoint
CREATE INDEX `assets_room_id_idx` ON `assets` (`room_id`);--> statement-breakpoint
CREATE TABLE `rooms` (
	`id` text NOT NULL,
	`user_id` text NOT NULL,
	`name` text NOT NULL,
	`group_type` text NOT NULL,
	`icon` text NOT NULL,
	`sort_order` integer DEFAULT 0 NOT NULL,
	`updated_at` text NOT NULL,
	`deleted_at` text,
	`purged_at` text,
	`version` integer DEFAULT 1 NOT NULL,
	PRIMARY KEY(`id`, `user_id`)
);
--> statement-breakpoint
CREATE INDEX `rooms_updated_at_idx` ON `rooms` (`updated_at`);--> statement-breakpoint
CREATE INDEX `rooms_user_id_idx` ON `rooms` (`user_id`);--> statement-breakpoint
CREATE TABLE `user_settings` (
	`user_id` text NOT NULL,
	`key` text NOT NULL,
	`value` text,
	`updated_at` text NOT NULL,
	PRIMARY KEY(`user_id`, `key`)
);
--> statement-breakpoint
CREATE TABLE `vision_usage` (
	`user_id` text NOT NULL,
	`date` text NOT NULL,
	`count` integer DEFAULT 0 NOT NULL,
	PRIMARY KEY(`user_id`, `date`)
);
