188 lines
7.5 KiB
PHP
188 lines
7.5 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class BookingRelationships extends Migration
|
|
{
|
|
|
|
public function up()
|
|
{
|
|
DB::statement("ALTER TABLE property_booking_payment_type MODIFY COLUMN code varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL");
|
|
|
|
DB::statement("ALTER TABLE property_booking_payment_type ADD INDEX (code)");
|
|
|
|
DB::statement("ALTER TABLE booking
|
|
ADD CONSTRAINT booking_ibfk_1 FOREIGN KEY (property_id)
|
|
REFERENCES property (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking
|
|
ADD CONSTRAINT booking_ibfk_3 FOREIGN KEY (currency_code)
|
|
REFERENCES currency (code) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking
|
|
ADD CONSTRAINT booking_ibfk_4 FOREIGN KEY (channel_id)
|
|
REFERENCES property_channel (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_contact
|
|
ADD CONSTRAINT booking_contact_ibfk_1 FOREIGN KEY (booking_id)
|
|
REFERENCES booking (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_payment
|
|
ADD CONSTRAINT booking_payment_ibfk_3 FOREIGN KEY (currency_code)
|
|
REFERENCES currency (code) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room
|
|
ADD CONSTRAINT booking_room_ibfk_1 FOREIGN KEY (booking_id)
|
|
REFERENCES booking (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room
|
|
ADD CONSTRAINT booking_room_ibfk_2 FOREIGN KEY (availability_id)
|
|
REFERENCES property_availability_type (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room
|
|
ADD CONSTRAINT booking_room_ibfk_3 FOREIGN KEY (room_id)
|
|
REFERENCES property_room (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room
|
|
ADD CONSTRAINT booking_room_ibfk_6 FOREIGN KEY (currency_code)
|
|
REFERENCES currency (code) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room_pax
|
|
ADD CONSTRAINT booking_room_pax_ibfk_1 FOREIGN KEY (booking_id)
|
|
REFERENCES booking (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room_pax
|
|
ADD CONSTRAINT booking_room_pax_ibfk_2 FOREIGN KEY (booking_room_id)
|
|
REFERENCES booking_room (id) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking
|
|
ADD CONSTRAINT booking_ibfk_2 FOREIGN KEY (payment_type_code)
|
|
REFERENCES property_booking_payment_type (code);");
|
|
|
|
DB::statement("ALTER TABLE booking_payment
|
|
ADD CONSTRAINT booking_payment_ibfk_2 FOREIGN KEY (payment_type_code)
|
|
REFERENCES property_booking_payment_type (code) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("ALTER TABLE booking_room
|
|
ADD CONSTRAINT booking_room_ibfk_5 FOREIGN KEY (payment_type_code)
|
|
REFERENCES property_booking_payment_type (code) ON DELETE RESTRICT ON UPDATE RESTRICT;");
|
|
|
|
DB::statement("
|
|
CREATE TABLE `payment_bin_number` (
|
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
|
`payment_type_id` int(11) DEFAULT NULL,
|
|
`bank_name` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
|
|
`bin_number` int(11) unsigned DEFAULT NULL,
|
|
`type` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
|
|
`class` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
|
|
`group` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
|
|
`card_type` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
|
|
`installment` varchar(255) COLLATE utf8_turkish_ci DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `IX_BIN_NUMBER` (`bin_number`)
|
|
);
|
|
");
|
|
|
|
DB::statement("
|
|
CREATE TABLE `payment_transaction` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`property_id` int(11) NOT NULL,
|
|
`payment_type_mapping_id` int(11) NOT NULL,
|
|
`code` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`order_id` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`bank_order_id` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`base_amount` double(10,2) DEFAULT NULL,
|
|
`base_currency` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`amount` double(10,2) NOT NULL,
|
|
`currency` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`installment` tinyint(3) DEFAULT '1',
|
|
`params` mediumtext COLLATE utf8mb4_unicode_ci,
|
|
`extra_params` mediumtext COLLATE utf8mb4_unicode_ci,
|
|
`message` mediumtext COLLATE utf8mb4_unicode_ci,
|
|
`response` mediumtext COLLATE utf8mb4_unicode_ci,
|
|
`status` tinyint(1) DEFAULT NULL COMMENT '0 => Error; 1 =>Success; 2=> Start, 3=> Pending, 4 => Cancel/Refund',
|
|
`created_at` int(11) DEFAULT NULL,
|
|
`updated_at` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
);
|
|
");
|
|
|
|
DB::statement("
|
|
CREATE TABLE `payment_type` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`pos_code` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`bank_code` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`threed_model` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`name` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`params` mediumtext COLLATE utf8mb4_unicode_ci,
|
|
`installment` tinyint(1) DEFAULT NULL COMMENT '0:Active, 1:Passive',
|
|
`status` tinyint(1) DEFAULT NULL COMMENT '0: Passive, 1: ActiveProd, 2: Test',
|
|
`created_by` int(11) DEFAULT NULL,
|
|
`updated_by` int(11) DEFAULT NULL,
|
|
`created_at` int(11) DEFAULT NULL,
|
|
`updated_at` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
);
|
|
");
|
|
|
|
DB::statement("
|
|
CREATE TABLE `property_payment_installment` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`property_id` int(11) NOT NULL,
|
|
`property_payment_mapping_id` int(11) NOT NULL,
|
|
`installment` tinyint(3) DEFAULT NULL,
|
|
`commission` double(10,2) NOT NULL,
|
|
`status` tinyint(1) DEFAULT NULL,
|
|
`created_by` int(11) DEFAULT NULL,
|
|
`updated_by` int(11) DEFAULT NULL,
|
|
`created_at` int(11) DEFAULT NULL,
|
|
`updated_at` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
);
|
|
");
|
|
|
|
DB::statement("
|
|
CREATE TABLE `property_payment_mapping` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`property_id` int(11) NOT NULL,
|
|
`payment_type_id` int(11) NOT NULL,
|
|
`params` mediumtext COLLATE utf8mb4_unicode_ci,
|
|
`installment` tinyint(1) DEFAULT NULL COMMENT '0:Active, 1:Passive',
|
|
`currency_code` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`is_default` tinyint(1) DEFAULT NULL,
|
|
`status` tinyint(1) DEFAULT NULL COMMENT '0: Passive, 1: ActiveProd, 2: Test',
|
|
`created_by` int(11) DEFAULT NULL,
|
|
`updated_by` int(11) DEFAULT NULL,
|
|
`created_at` int(11) DEFAULT NULL,
|
|
`updated_at` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
);
|
|
");
|
|
|
|
DB::statement("
|
|
CREATE TABLE `currency_rates` (
|
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
`date` date DEFAULT NULL,
|
|
`currency_code` varchar(3) CHARACTER SET utf8 DEFAULT NULL,
|
|
`exc_currency_code` varchar(3) CHARACTER SET utf8 DEFAULT NULL,
|
|
`rate` double(10,2) DEFAULT NULL,
|
|
`custom_rate` double(10,2) DEFAULT NULL,
|
|
`created_at` int(11) DEFAULT NULL,
|
|
`updated_at` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
);
|
|
");
|
|
|
|
|
|
}
|
|
|
|
|
|
public function down()
|
|
{
|
|
//
|
|
}
|
|
}
|