282 lines
9.1 KiB
SQL
282 lines
9.1 KiB
SQL
create table
|
|
`users` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`name` varchar(255) not null,
|
|
`email` varchar(255) not null,
|
|
`email_verified_at` timestamp null,
|
|
`password` varchar(255) not null,
|
|
`remember_token` varchar(100) null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `users` add unique `users_email_unique` (`email`);
|
|
|
|
create table
|
|
`password_reset_tokens` (
|
|
`email` varchar(255) not null,
|
|
`token` varchar(255) not null,
|
|
`created_at` timestamp null,
|
|
primary key (`email`)
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`sessions` (
|
|
`id` varchar(255) not null,
|
|
`user_id` bigint unsigned null,
|
|
`ip_address` varchar(45) null,
|
|
`user_agent` text null,
|
|
`payload` longtext not null,
|
|
`last_activity` int not null,
|
|
primary key (`id`)
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `sessions` add index `sessions_user_id_index` (`user_id`);
|
|
|
|
alter table `sessions` add index `sessions_last_activity_index` (`last_activity`);
|
|
|
|
create table
|
|
`cache` (
|
|
`key` varchar(255) not null,
|
|
`value` mediumtext not null,
|
|
`expiration` int not null,
|
|
primary key (`key`)
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`cache_locks` (
|
|
`key` varchar(255) not null,
|
|
`owner` varchar(255) not null,
|
|
`expiration` int not null,
|
|
primary key (`key`)
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`jobs` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`queue` varchar(255) not null,
|
|
`payload` longtext not null,
|
|
`attempts` tinyint unsigned not null,
|
|
`reserved_at` int unsigned null,
|
|
`available_at` int unsigned not null,
|
|
`created_at` int unsigned not null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `jobs` add index `jobs_queue_index` (`queue`);
|
|
|
|
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` longtext not null,
|
|
`options` mediumtext null,
|
|
`cancelled_at` int null,
|
|
`created_at` int not null,
|
|
`finished_at` int null,
|
|
primary key (`id`)
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`failed_jobs` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`uuid` varchar(255) not null,
|
|
`connection` text not null,
|
|
`queue` text not null,
|
|
`payload` longtext not null,
|
|
`exception` longtext not null,
|
|
`failed_at` timestamp not null default CURRENT_TIMESTAMP
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `failed_jobs` add unique `failed_jobs_uuid_unique` (`uuid`);
|
|
|
|
create table
|
|
`packings` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`name` varchar(255) not null,
|
|
`size` decimal(10, 2) not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`recipes` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`name` varchar(255) not null,
|
|
`description` text null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`spices` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`name` varchar(255) not null,
|
|
`quantity` decimal(10, 2) not null default '0',
|
|
`unit` varchar(255) not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`suppliers` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`name` varchar(255) not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
create table
|
|
`spices_suppliers` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`spice_id` bigint unsigned not null,
|
|
`supplier_id` bigint unsigned not null,
|
|
`amount` decimal(10, 2) not null,
|
|
`supplied_at` timestamp null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `spices_suppliers` add constraint `spices_suppliers_spice_id_foreign` foreign key (`spice_id`) references `spices` (`id`) on delete cascade;
|
|
|
|
alter table `spices_suppliers` add constraint `spices_suppliers_supplier_id_foreign` foreign key (`supplier_id`) references `suppliers` (`id`) on delete cascade;
|
|
|
|
create table
|
|
`products` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`title` text not null,
|
|
`images` json null,
|
|
`description` text null,
|
|
`package_content` text null,
|
|
`recipes_id` bigint unsigned not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `products` add constraint `products_recipes_id_foreign` foreign key (`recipes_id`) references `recipes` (`id`) on delete cascade;
|
|
|
|
alter table `products` add unique `products_gtin_unique` (`gtin`);
|
|
|
|
create table
|
|
`products_sizes` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`product_id` bigint unsigned not null,
|
|
`packing_id` bigint unsigned not null,
|
|
`gtin` bigint unsigned,
|
|
`description` varchar(255) null,
|
|
`price` float (53) not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `products_sizes` add constraint `products_sizes_product_id_foreign` foreign key (`product_id`) references `products` (`id`) on delete cascade;
|
|
|
|
alter table `products_sizes` add constraint `products_sizes_packing_id_foreign` foreign key (`packing_id`) references `packings` (`id`) on delete cascade;
|
|
|
|
create table
|
|
`products_inventory` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`product_id` bigint unsigned not null,
|
|
`size_id` bigint unsigned not null,
|
|
`out_at` timestamp null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `products_inventory` add constraint `products_inventory_product_id_foreign` foreign key (`product_id`) references `products` (`id`);
|
|
|
|
alter table `products_inventory` add constraint `products_inventory_size_id_foreign` foreign key (`size_id`) references `products_sizes` (`id`);
|
|
|
|
create table
|
|
`products_sales` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`product_id` bigint unsigned not null,
|
|
`size_id` bigint unsigned not null,
|
|
`amount` int not null,
|
|
`comment` text null,
|
|
`sold_at` timestamp not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `products_sales` add constraint `products_sales_product_id_foreign` foreign key (`product_id`) references `products` (`id`);
|
|
|
|
alter table `products_sales` add constraint `products_sales_size_id_foreign` foreign key (`size_id`) references `products_sizes` (`id`);
|
|
|
|
create table
|
|
`recipes_spices` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`recipe_id` bigint unsigned not null,
|
|
`spice_id` bigint unsigned not null,
|
|
`amount_in_percent` decimal(4, 2) not null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `recipes_spices` add constraint `recipes_spices_recipe_id_foreign` foreign key (`recipe_id`) references `recipes` (`id`) on delete cascade;
|
|
|
|
alter table `recipes_spices` add constraint `recipes_spices_spice_id_foreign` foreign key (`spice_id`) references `spices` (`id`) on delete cascade;
|
|
|
|
create table
|
|
`activity_log` (
|
|
`id` bigint unsigned not null auto_increment primary key,
|
|
`log_name` varchar(255) null,
|
|
`description` text not null,
|
|
`subject_type` varchar(255) null,
|
|
`subject_id` bigint unsigned null,
|
|
`causer_type` varchar(255) null,
|
|
`causer_id` bigint unsigned null,
|
|
`properties` json null,
|
|
`created_at` timestamp null,
|
|
`updated_at` timestamp null
|
|
) default character
|
|
set
|
|
utf8mb4 collate 'utf8mb4_unicode_ci';
|
|
|
|
alter table `activity_log` add index `subject` (`subject_type`, `subject_id`);
|
|
|
|
alter table `activity_log` add index `causer` (`causer_type`, `causer_id`);
|
|
|
|
alter table `activity_log` add index `activity_log_log_name_index` (`log_name`);
|
|
|
|
alter table `activity_log` add `event` varchar(255) null after `subject_type`;
|
|
|
|
alter table `activity_log` add `batch_uuid` char(36) null after `properties`; |