CREATE TABLE IF NOT EXISTS "migrations" ("id" INT primary key auto_increment not null, "migration" varchar not null, "batch" INT not null);
INSERT INTO migrations VALUES(1,'0001_01_01_000000_create_users_table',1);
INSERT INTO migrations VALUES(2,'0001_01_01_000001_create_cache_table',1);
INSERT INTO migrations VALUES(3,'0001_01_01_000002_create_jobs_table',1);
INSERT INTO migrations VALUES(4,'2025_07_03_051105_create_permission_tables',2);
INSERT INTO migrations VALUES(5,'2025_07_07_032528_create_customers_table',3);
INSERT INTO migrations VALUES(6,'2025_07_08_042153_create_pawned_items_table',3);
INSERT INTO migrations VALUES(7,'2025_07_08_042406_create_pawned_transactions_table',3);
INSERT INTO migrations VALUES(9,'2025_07_08_095740_create_gadgets_table',4);
INSERT INTO migrations VALUES(12,'2025_07_10_092414_create_transactions_table',5);
CREATE TABLE IF NOT EXISTS "password_reset_tokens" ("email" varchar not null, "token" varchar not null, "created_at" datetime, primary key ("email"));
CREATE TABLE IF NOT EXISTS "sessions" ("id" varchar not null, "user_id" INT, "ip_address" varchar, "user_agent" text, "payload" text not null, "last_activity" INT not null, primary key ("id"));
INSERT INTO sessions VALUES('QuAXYTLexdG7N0jHsbuXfEGsHIAwlW2L7gPTcwoW',1,'127.0.0.1','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36','YTo1OntzOjY6Il90b2tlbiI7czo0MDoibm1GZG9YWUgyMFpSQjZrdnloNmxRdnE0bjZ6c1RyYmF2OGNybWF0WCI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MzM6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9hZG1pbi9yb2xlcyI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fXM6NTA6ImxvZ2luX3dlYl81OWJhMzZhZGRjMmIyZjk0MDE1ODBmMDE0YzdmNThlYTRlMzA5ODlkIjtpOjE7czoxNzoicGFzc3dvcmRfaGFzaF93ZWIiO3M6NjA6IiQyeSQxMiR4eTQuREFuM1FjNGFOTENwTHpjZU91TXE5VTZsVHUwdWM4eDBTNGN4Ulo2VEU3TUt2WTVGNiI7fQ==',1752682137);
CREATE TABLE IF NOT EXISTS "cache" ("key" varchar not null, "value" text not null, "expiration" INT not null, primary key ("key"));
INSERT INTO cache VALUES('356a192b7913b04c54574d18c28d46e6395428ab:timer','i:1752164972;',1752164972);
INSERT INTO cache VALUES('356a192b7913b04c54574d18c28d46e6395428ab','i:1;',1752164972);
INSERT INTO cache VALUES('spatie.permission.cache','a:3:{s:5:"alias";a:4:{s:1:"a";s:2:"id";s:1:"b";s:4:"name";s:1:"c";s:10:"guard_name";s:1:"r";s:5:"roles";}s:11:"permissions";a:2:{i:0;a:4:{s:1:"a";i:1;s:1:"b";s:9:"customers";s:1:"c";s:3:"web";s:1:"r";a:1:{i:0;i:2;}}i:1;a:4:{s:1:"a";i:2;s:1:"b";s:7:"gadgets";s:1:"c";s:3:"web";s:1:"r";a:1:{i:0;i:2;}}}s:5:"roles";a:1:{i:0;a:3:{s:1:"a";i:2;s:1:"b";s:7:"cashier";s:1:"c";s:3:"web";}}}',1752723926);
INSERT INTO cache VALUES('livewire-rate-limiter:a17961fa74e9275d529f489537f179c05d50c2f3:timer','i:1752681416;',1752681416);
INSERT INTO cache VALUES('livewire-rate-limiter:a17961fa74e9275d529f489537f179c05d50c2f3','i:1;',1752681416);
CREATE TABLE IF NOT EXISTS "cache_locks" ("key" varchar not null, "owner" varchar not null, "expiration" INT not null, primary key ("key"));
CREATE TABLE IF NOT EXISTS "jobs" ("id" INT primary key auto_increment not null, "queue" varchar not null, "payload" text not null, "attempts" INT not null, "reserved_at" INT, "available_at" INT not null, "created_at" INT not null);
CREATE TABLE IF NOT EXISTS "job_batches" ("id" varchar not null, "name" varchar not null, "total_jobs" INT not null, "pending_jobs" INT not null, "failed_jobs" INT not null, "failed_job_ids" text not null, "options" text, "cancelled_at" INT, "created_at" INT not null, "finished_at" INT, primary key ("id"));
CREATE TABLE IF NOT EXISTS "failed_jobs" ("id" INT primary key auto_increment not null, "uuid" varchar not null, "connection" text not null, "queue" text not null, "payload" text not null, "exception" text not null, "failed_at" datetime not null default CURRENT_TIMESTAMP);
CREATE TABLE IF NOT EXISTS "permissions" ("id" INT primary key auto_increment not null, "name" varchar not null, "guard_name" varchar not null, "created_at" datetime, "updated_at" datetime);
INSERT INTO permissions VALUES(1,'customers','web','2025-07-10 07:07:09','2025-07-10 07:07:09');
INSERT INTO permissions VALUES(2,'gadgets','web','2025-07-10 07:07:26','2025-07-10 07:07:26');
CREATE TABLE IF NOT EXISTS "roles" ("id" INT primary key auto_increment not null, "name" varchar not null, "guard_name" varchar not null, "created_at" datetime, "updated_at" datetime);
INSERT INTO roles VALUES(1,'admin','web','2025-07-03 06:11:40','2025-07-03 06:11:40');
INSERT INTO roles VALUES(2,'cashier','web','2025-07-10 07:07:50','2025-07-10 07:07:50');
CREATE TABLE IF NOT EXISTS "model_has_permissions" ("permission_id" INT not null, "model_type" varchar not null, "model_id" INT not null, foreign key("permission_id") references "permissions"("id") on delete cascade, primary key ("permission_id", "model_id", "model_type"));
CREATE TABLE IF NOT EXISTS "model_has_roles" ("role_id" INT not null, "model_type" varchar not null, "model_id" INT not null, foreign key("role_id") references "roles"("id") on delete cascade, primary key ("role_id", "model_id", "model_type"));
INSERT INTO model_has_roles VALUES(1,'App\Models\User',1);
INSERT INTO model_has_roles VALUES(2,'App\Models\User',2);
CREATE TABLE IF NOT EXISTS "role_has_permissions" ("permission_id" INT not null, "role_id" INT not null, foreign key("permission_id") references "permissions"("id") on delete cascade, foreign key("role_id") references "roles"("id") on delete cascade, primary key ("permission_id", "role_id"));
INSERT INTO role_has_permissions VALUES(1,2);
INSERT INTO role_has_permissions VALUES(2,2);
CREATE TABLE IF NOT EXISTS "customers" ("id" INT primary key auto_increment not null, "name" varchar not null, "ktp_no" varchar not null, "phone" varchar not null, "address" varchar not null, "email" varchar, "ktp_document" text not null, "created_at" datetime, "updated_at" datetime);
CREATE TABLE IF NOT EXISTS "pawned_items" ("id" INT primary key auto_increment not null, "created_at" datetime, "updated_at" datetime);
CREATE TABLE IF NOT EXISTS "pawned_transactions" ("id" INT primary key auto_increment not null, "created_at" datetime, "updated_at" datetime);
CREATE TABLE IF NOT EXISTS "gadgets" ("id" INT primary key auto_increment not null, "customer_id" INT not null, "brand" varchar not null, "model" varchar not null, "imei" varchar not null, "pawn_value" INT not null, "admin_fee" INT not null, "service_fee" INT not null, "start_date" date not null, "end_date" date not null, "status" varchar check ("status" in ('active', 'redeem', 'sold')) not null, "hp_ram" INT not null, "hp_rom" INT not null, "cf_case_condition" varchar not null, "cf_case_quality" varchar not null, "cf_glue_marks" varchar not null, "cf_lcd_condition" varchar not null, "cf_lcd_quality" varchar not null, "cs_battery_condition" varchar not null, "cs_battery_quality" varchar not null, "cs_restart3x_condition" varchar not null, "cs_restart3x_quality" varchar not null, "cs_screen_condition" varchar not null, "cs_screen_quality" varchar not null, "cs_sensor_condition" varchar not null, "cs_sensor_quality" varchar not null, "cs_sound_condition" varchar not null, "cs_sound_quality" varchar not null, "cs_ring_condition" varchar not null, "cs_ring_quality" varchar not null, "cs_flashlight_condition" varchar not null, "cs_flashlight_quality" varchar not null, "cs_screenfunction_condition" varchar not null, "cs_screenfunction_quality" varchar not null, "cs_charger_condition" varchar not null, "cs_charger_quality" varchar not null, "cs_front_cam_condition" varchar not null, "cs_front_cam_quality" varchar not null, "cs_main_cam_condition" varchar not null, "cs_main_cam_quality" varchar not null, "cs_signal_condition" varchar not null, "cs_signal_quality" varchar not null, "imei_box_phone" varchar not null, "charger_condition" varchar not null, "charger_status" varchar not null, "box" varchar not null, "ram_condition" varchar not null, "rom_condition" varchar not null, "account_check" varchar not null, "completeness" varchar not null, "signature" varchar not null, "device_check_playstore" varchar not null, "user_id" varchar not null, "created_at" datetime, "updated_at" datetime, foreign key("customer_id") references "customers"("id") on delete cascade);
CREATE TABLE IF NOT EXISTS "transactions" ("id" INT primary key auto_increment not null, "type" varchar check ("type" in ('cash_in', 'cash_out')) not null, "gadget_id" INT, "user_id" INT, "amount" numeric not null, "due_date" date not null, "category" varchar not null, "notes" text, "nomor_nota" varchar, "created_at" datetime, "updated_at" datetime, foreign key("gadget_id") references "gadgets"("id") on delete cascade, foreign key("user_id") references "users"("id") on delete set null);
CREATE INDEX "sessions_user_id_index" on "sessions" ("user_id");
CREATE INDEX "sessions_last_activity_index" on "sessions" ("last_activity");
CREATE INDEX "jobs_queue_index" on "jobs" ("queue");
CREATE UNIQUE INDEX "failed_jobs_uuid_unique" on "failed_jobs" ("uuid");
CREATE UNIQUE INDEX "permissions_name_guard_name_unique" on "permissions" ("name", "guard_name");
CREATE UNIQUE INDEX "roles_name_guard_name_unique" on "roles" ("name", "guard_name");
CREATE INDEX "model_has_permissions_model_id_model_type_index" on "model_has_permissions" ("model_id", "model_type");
CREATE INDEX "model_has_roles_model_id_model_type_index" on "model_has_roles" ("model_id", "model_type");
CREATE UNIQUE INDEX "customers_ktp_no_unique" on "customers" ("ktp_no");
COMMIT;
