PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_sessions` (
	`id` text PRIMARY KEY NOT NULL,
	`branch_id` text NOT NULL,
	`customer_id` text,
	`mode` text NOT NULL,
	`status` text NOT NULL,
	`started_at` integer NOT NULL,
	`ended_at` integer,
	`prepaid_minutes` integer,
	`total_cost` integer DEFAULT 0 NOT NULL,
	`opened_by_staff` text,
	`opened_via` text DEFAULT 'staff' NOT NULL,
	`notes` text
);
--> statement-breakpoint
INSERT INTO `__new_sessions`("id", "branch_id", "customer_id", "mode", "status", "started_at", "ended_at", "prepaid_minutes", "total_cost", "opened_by_staff", "opened_via", "notes") SELECT "id", "branch_id", "customer_id", "mode", "status", "started_at", "ended_at", "prepaid_minutes", "total_cost", "opened_by_staff", 'staff', "notes" FROM `sessions`;--> statement-breakpoint
DROP TABLE `sessions`;--> statement-breakpoint
ALTER TABLE `__new_sessions` RENAME TO `sessions`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE INDEX `sessions_status_idx` ON `sessions` (`status`);--> statement-breakpoint
CREATE INDEX `sessions_customer_idx` ON `sessions` (`customer_id`);--> statement-breakpoint
ALTER TABLE `customers` ADD `password_hash` text;