migration issues

This commit is contained in:
2024-04-04 17:53:23 +05:45
parent df0cbdf8a0
commit dfdc927a56
11 changed files with 213 additions and 219 deletions

View File

@ -185,7 +185,8 @@ class OMIS
]);
}
}
private function initDB()
public static function initDB()
{
static $initialized = false;
if (!$initialized) {
@ -225,64 +226,64 @@ class OMIS
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_users` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(255) NULL,
`email` varchar(255) NULL,
`username` varchar(255) NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) NULL,
`remember_token` varchar(100) DEFAULT NULL,
`display_order` INT(11) DEFAULT 1,
`roles_id` INT(11),
`branches_id` INT(11),
`vendors_id` INT(11),
`employees_id` INT(11),
`status` INT(11) DEFAULT 1,
`created_at` timestamp NULL DEFAULT NULL,
`createdby` INT(11),
`updated_at` timestamp NULL DEFAULT NULL,
`updatedby` INT(11)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
DB::statement("CREATE TABLE IF NOT EXISTS tbl_roles (
role_id INT(11) AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255),
alias VARCHAR(255),
description TEXT,
display_order INT(11),
status INT(11),
remarks TEXT,
created_at DATETIME,
createdby INT(11),
updated_at DATETIME,
updatedby INT(11)
);");
DB::statement("CREATE TABLE IF NOT EXISTS tbl_permissions (
permission_id INT(11) AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255),
alias VARCHAR(255),
modal VARCHAR(255),
command VARCHAR(255),
created_at DATETIME,
createdby INT(11),
updated_at DATETIME,
updatedby INT(11),
status INT(11)
// DB::statement("CREATE TABLE IF NOT EXISTS `tbl_users` (
// `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
// `name` varchar(255) NULL,
// `email` varchar(255) NULL,
// `username` varchar(255) NULL,
// `email_verified_at` timestamp NULL DEFAULT NULL,
// `password` varchar(255) NULL,
// `remember_token` varchar(100) DEFAULT NULL,
// `display_order` INT(11) DEFAULT 1,
// `roles_id` INT(11),
// `branches_id` INT(11),
// `vendors_id` INT(11),
// `employees_id` INT(11),
// `status` INT(11) DEFAULT 1,
// `created_at` timestamp NULL DEFAULT NULL,
// `createdby` INT(11),
// `updated_at` timestamp NULL DEFAULT NULL,
// `updatedby` INT(11)
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
// ");
// DB::statement("CREATE TABLE IF NOT EXISTS tbl_roles (
// role_id INT(11) AUTO_INCREMENT PRIMARY KEY,
// title VARCHAR(255),
// alias VARCHAR(255),
// description TEXT,
// display_order INT(11),
// status INT(11),
// remarks TEXT,
// created_at DATETIME,
// createdby INT(11),
// updated_at DATETIME,
// updatedby INT(11)
// );");
// DB::statement("CREATE TABLE IF NOT EXISTS tbl_permissions (
// permission_id INT(11) AUTO_INCREMENT PRIMARY KEY,
// title VARCHAR(255),
// alias VARCHAR(255),
// modal VARCHAR(255),
// command VARCHAR(255),
// created_at DATETIME,
// createdby INT(11),
// updated_at DATETIME,
// updatedby INT(11),
// status INT(11)
);");
DB::statement("CREATE TABLE IF NOT EXISTS tbl_rolepermissions (
rolepermission_id INT(11) AUTO_INCREMENT PRIMARY KEY,
roles_id INT(11),
permissions_id INT(11),
display_order INT(11),
remarks VARCHAR(255),
created_at DATETIME,
createdby INT(11),
updated_at DATETIME,
updatedby INT(11),
status INT(11)
);");
// );");
// DB::statement("CREATE TABLE IF NOT EXISTS tbl_rolepermissions (
// rolepermission_id INT(11) AUTO_INCREMENT PRIMARY KEY,
// roles_id INT(11),
// permissions_id INT(11),
// display_order INT(11),
// remarks VARCHAR(255),
// created_at DATETIME,
// createdby INT(11),
// updated_at DATETIME,
// updatedby INT(11),
// status INT(11)
// );");
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_settings` (
`setting_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) NULL,
@ -509,8 +510,7 @@ class OMIS
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_castes` (
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_castes` (
`caste_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
@ -524,8 +524,7 @@ class OMIS
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_ethnicities` (
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_ethnicities` (
`ethnicity_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
@ -539,8 +538,7 @@ class OMIS
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_dags` (
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_dags` (
`dag_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
@ -554,83 +552,12 @@ class OMIS
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_nationalities` (
`nationality_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`remarks` varchar(255) DEFAULT NULL,
`display_order` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`createdby` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`updatedby` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_employees` (
`employee_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`first_name` varchar(255) DEFAULT NULL,
`middle_name` varchar(255) DEFAULT NULL,
`last_name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`genders_id` int(11) DEFAULT NULL,
`nepali_dob` date DEFAULT NULL,
`dob` date DEFAULT NULL,
`nationalities_id` int(11) DEFAULT NULL,
`about_me` text,
`signature` varchar(255) DEFAULT NULL,
`father_name` varchar(255) DEFAULT NULL,
`mother_name` varchar(255) DEFAULT NULL,
`grand_father_name` varchar(255) DEFAULT NULL,
`grand_mother_name` varchar(255) DEFAULT NULL,
`spouse` varchar(255) DEFAULT NULL,
`contact` varchar(255) DEFAULT NULL,
`alt_contact` varchar(255) DEFAULT NULL,
`profile_picture` varchar(255) DEFAULT NULL,
`users_id` int(11) DEFAULT NULL,
`is_login_required` tinyint(1) DEFAULT NULL,
`skills` text,
`experience` text,
`permanent_address` text,
`permanent_city` int(11) DEFAULT NULL,
`temporary_address` text,
`temporary_city` int(11) DEFAULT NULL,
`old_system_address` text,
`education` text,
`castes_id` int(11) DEFAULT NULL,
`ethnicities_id` int(11) DEFAULT NULL,
`dags_id` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`display_order` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`createdby` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`updatedby` int(11) DEFAULT NULL,
`remarks` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_onboardings` (
`onboarding_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`doj` datetime DEFAULT NULL,
`designations_id` int(11) DEFAULT NULL,
`position_status` varchar(255) DEFAULT NULL,
`departments_id` int(11) DEFAULT NULL,
`shifts_id` int(11) DEFAULT NULL,
`agreement` varchar(255) DEFAULT NULL,
`nda` varchar(255) DEFAULT NULL,
`terms` text DEFAULT NULL,
`workoptions` varchar(255) DEFAULT NULL,
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_nationalities` (
`nationality_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`remarks` text DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`remarks` varchar(255) DEFAULT NULL,
`display_order` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`createdby` int(11) DEFAULT NULL,
@ -639,6 +566,75 @@ class OMIS
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
// DB::statement("CREATE TABLE IF NOT EXISTS `tbl_employees` (
// `employee_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
// `first_name` varchar(255) DEFAULT NULL,
// `middle_name` varchar(255) DEFAULT NULL,
// `last_name` varchar(255) DEFAULT NULL,
// `email` varchar(255) DEFAULT NULL,
// `genders_id` int(11) DEFAULT NULL,
// `nepali_dob` date DEFAULT NULL,
// `dob` date DEFAULT NULL,
// `nationalities_id` int(11) DEFAULT NULL,
// `about_me` text,
// `signature` varchar(255) DEFAULT NULL,
// `father_name` varchar(255) DEFAULT NULL,
// `mother_name` varchar(255) DEFAULT NULL,
// `grand_father_name` varchar(255) DEFAULT NULL,
// `grand_mother_name` varchar(255) DEFAULT NULL,
// `spouse` varchar(255) DEFAULT NULL,
// `contact` varchar(255) DEFAULT NULL,
// `alt_contact` varchar(255) DEFAULT NULL,
// `profile_picture` varchar(255) DEFAULT NULL,
// `users_id` int(11) DEFAULT NULL,
// `is_login_required` tinyint(1) DEFAULT NULL,
// `skills` text,
// `experience` text,
// `permanent_address` text,
// `permanent_city` int(11) DEFAULT NULL,
// `temporary_address` text,
// `temporary_city` int(11) DEFAULT NULL,
// `old_system_address` text,
// `education` text,
// `castes_id` int(11) DEFAULT NULL,
// `ethnicities_id` int(11) DEFAULT NULL,
// `dags_id` int(11) DEFAULT NULL,
// `title` varchar(255) DEFAULT NULL,
// `alias` varchar(255) DEFAULT NULL,
// `status` varchar(255) DEFAULT NULL,
// `display_order` int(11) DEFAULT NULL,
// `created_at` timestamp NULL DEFAULT NULL,
// `createdby` int(11) DEFAULT NULL,
// `updated_at` timestamp NULL DEFAULT NULL,
// `updatedby` int(11) DEFAULT NULL,
// `remarks` varchar(255) DEFAULT NULL
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
// ");
// DB::statement("
// CREATE TABLE IF NOT EXISTS `tbl_onboardings` (
// `onboarding_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
// `doj` datetime DEFAULT NULL,
// `designations_id` int(11) DEFAULT NULL,
// `position_status` varchar(255) DEFAULT NULL,
// `departments_id` int(11) DEFAULT NULL,
// `shifts_id` int(11) DEFAULT NULL,
// `agreement` varchar(255) DEFAULT NULL,
// `nda` varchar(255) DEFAULT NULL,
// `terms` text DEFAULT NULL,
// `workoptions` varchar(255) DEFAULT NULL,
// `title` varchar(255) DEFAULT NULL,
// `alias` varchar(255) DEFAULT NULL,
// `status` int(11) DEFAULT NULL,
// `remarks` text DEFAULT NULL,
// `display_order` int(11) DEFAULT NULL,
// `created_at` timestamp NULL DEFAULT NULL,
// `createdby` int(11) DEFAULT NULL,
// `updated_at` timestamp NULL DEFAULT NULL,
// `updatedby` int(11) DEFAULT NULL
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
// ");
// Dharamaraj
DB::statement("
@ -705,58 +701,43 @@ class OMIS
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_leavetypes` (
`leavetype_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`remarks` text DEFAULT NULL,
`display_order` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`createdby` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`updatedby` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
// DB::statement("
// CREATE TABLE IF NOT EXISTS `tbl_leavetypes` (
// `leavetype_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
// `title` varchar(255) DEFAULT NULL,
// `alias` varchar(255) DEFAULT NULL,
// `status` int(11) DEFAULT NULL,
// `remarks` text DEFAULT NULL,
// `display_order` int(11) DEFAULT NULL,
// `created_at` timestamp NULL DEFAULT NULL,
// `createdby` int(11) DEFAULT NULL,
// `updated_at` timestamp NULL DEFAULT NULL,
// `updatedby` int(11) DEFAULT NULL
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
// ");
DB::statement("
CREATE TABLE IF NOT EXISTS `tbl_leaves` (
`leave_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`remarks` text DEFAULT NULL,
`display_order` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`createdby` int(11) DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`updatedby` int(11) DEFAULT NULL,
`leavetypes_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
");
// if (!(DB::table('users')->first())) {
// DB::statement("INSERT INTO `users` (`name`,`email`,`username`,`password`,`roles_id`,`status`) VALUES ('Prajwal Adhikari','prajwalbro@hotmail.com','prajwalbro@hotmail.com','$2y$10$3zlF9VeXexzWKRDPZuDio.W7RZIC3tU.cjwMoLzG8ki8bVwAQn1WW','1','1');");
// }
if (!(DB::table('users')->first())) {
DB::statement("INSERT INTO `tbl_users` (`name`,`email`,`username`,`password`,`roles_id`,`status`) VALUES ('Prajwal Adhikari','prajwalbro@hotmail.com','prajwalbro@hotmail.com','$2y$10$3zlF9VeXexzWKRDPZuDio.W7RZIC3tU.cjwMoLzG8ki8bVwAQn1WW','1','1');");
}
if (!(DB::table('settings')->first())) {
DB::statement("INSERT INTO `tbl_settings` (`title`, `description`, `status`) VALUES ('Bibhuti OMIS', '', '1');");
}
// if (!(DB::table('settings')->first())) {
// DB::statement("INSERT INTO `tbl_settings` (`title`, `description`, `status`) VALUES ('Bibhuti OMIS', '', '1');");
// }
if (!(DB::table('countries')->first())) {
DB::statement("INSERT INTO `tbl_countries` (`title`,`alias`,`status`) VALUES ('Nepal','nepal', '1');");
}
if (!(DB::table('proviences')->first())) {
DB::statement("INSERT INTO `tbl_proviences` (`title`,`alias`,`status`) VALUES ('Bagmati','bagmati', '1');");
}
// if (!(DB::table('countries')->first())) {
// DB::statement("INSERT INTO `tbl_countries` (`title`,`alias`,`status`) VALUES ('Nepal','nepal', '1');");
// }
// if (!(DB::table('proviences')->first())) {
// DB::statement("INSERT INTO `tbl_proviences` (`title`,`alias`,`status`) VALUES ('Bagmati','bagmati', '1');");
// }
if (!(DB::table('roles')->first())) {
DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Admin','admin','1');");
DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Manager','manager','1');");
DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Branch','branch','1');");
DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Agent','agent','1');");
DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Student','student','1');");
}
// if (!(DB::table('roles')->first())) {
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Admin','admin','1');");
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Manager','manager','1');");
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Branch','branch','1');");
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Agent','agent','1');");
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Student','student','1');");
// }
$initialized = true;
}