-- ClearBank MySQL Export (Fixed)
-- Generated: 2026-08-26 19:38:07

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

-- --------------------------------------------------------

CREATE TABLE `users` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `name` varchar(255) not null, `username` varchar(255) not null, `email` varchar(255) not null, `phone` varchar(255), `address` varchar(255), `date_of_birth` varchar(255), `plan_type` varchar(255) not null default 'basic', `balance` numeric not null default '0', `account_number` varchar(255), `iban` varchar(255), `swift` varchar(255), `is_admin` tinyint(1) not null default '0', `email_verified_at` datetime, `password` varchar(255) not null, `remember_token` varchar(255), `created_at` datetime, `updated_at` datetime);

-- --------------------------------------------------------

CREATE TABLE `accounts` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `user_id` int not null, `account_type` varchar(255) not null default 'checking', `currency` varchar(255) not null default 'EUR', `balance` numeric not null default '0', `account_number` varchar(255) not null, `iban` varchar(255) not null, `swift` varchar(255), `status` varchar(255) not null default 'active', `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- --------------------------------------------------------

CREATE TABLE `transactions` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `user_id` int not null, `type` varchar(255) not null default 'transfer', `amount` numeric not null, `currency` varchar(255) not null default 'EUR', `recipient_name` varchar(255), `recipient_iban` varchar(255), `recipient_swift` varchar(255), `description` text, `status` varchar(255) not null default 'pending', `reference` varchar(255) not null, `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- --------------------------------------------------------

CREATE TABLE `contacts` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `user_id` int not null, `name` varchar(255) not null, `iban` varchar(255), `swift` varchar(255), `email` varchar(255), `phone` varchar(255), `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- --------------------------------------------------------

CREATE TABLE `savings_accounts` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `user_id` int not null, `account_id` int not null, `interest_rate` numeric not null default '4.5', `balance` numeric not null default '0', `status` varchar(255) not null default 'inactive', `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade, foreign key(`account_id`) references `accounts`(`id`) on delete cascade);

-- --------------------------------------------------------

CREATE TABLE `cache` (`key` varchar(255) not null, `value` text not null, `expiration` int not null, primary key (`key`));

-- --------------------------------------------------------

CREATE TABLE `cache_locks` (`key` varchar(255) not null, `owner` varchar(255) not null, `expiration` int not null, primary key (`key`));

-- --------------------------------------------------------

CREATE TABLE `failed_jobs` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `uuid` varchar(255) 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 `job_batches` (`id` varchar(255) not null, `name` varchar(255) 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 `jobs` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `queue` varchar(255) 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 `migrations` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `migration` varchar(255) not null, `batch` int not null);

-- --------------------------------------------------------

CREATE TABLE `sessions` (`id` varchar(255) not null, `user_id` int, `ip_address` varchar(255), `user_agent` text, `payload` text not null, `last_activity` int not null, primary key (`id`));

-- --------------------------------------------------------

CREATE TABLE `support_tickets` (`id` INT PRIMARY KEY AUTO_INCREMENT not null, `user_id` int not null, `subject` varchar(255) not null, `message` text not null, `status` varchar(255) not null default 'open', `priority` varchar(255) not null default 'medium', `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- --------------------------------------------------------

INSERT INTO `users` (`id`, `name`, `username`, `email`, `phone`, `address`, `date_of_birth`, `plan_type`, `balance`, `account_number`, `iban`, `swift`, `is_admin`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
('1', 'Admin', 'admin', 'admin@clearb.org', NULL, NULL, NULL, 'vip', '50000', 'ACC6a8efacf091c8', 'DEKAMF91DYI230OGN7LBWVE4', '5CJLTETV', '1', NULL, '$2y$12$xYDbWNALyG1nysBn5q9w0.waHvKJGe.h8fQjjv.iI.vbC9ajmOyxe', NULL, '2026-08-26 14:40:15', '2026-08-26 14:40:15');

-- --------------------------------------------------------
-- Admin user: admin@clearb.org / password
-- Change password after first login!
