-
Notifications
You must be signed in to change notification settings - Fork 0
/
_db.php
81 lines (72 loc) · 2.44 KB
/
_db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require_once('config.php');
date_default_timezone_set("Europe/Vienna");
$db = new PDO("mysql:host={$config['db']['host']};port={$config['db']['port']};charset=utf8",
$config['db']['user'],
$config['db']['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("CREATE DATABASE IF NOT EXISTS `{$config['db']['db_name']}` /*!40100 COLLATE 'utf8_general_ci' */");
$db->exec("use `{$config['db']['db_name']}`");
$db->exec("CREATE TABLE IF NOT EXISTS `auth_codes` (
`id` VARCHAR(36) NOT NULL,
`request_sent` TINYINT(1) NOT NULL DEFAULT 0,
`auth_code` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'");
$db->exec("CREATE TABLE IF NOT EXISTS `apaleo_tokens` (
`id` varchar(255) NOT NULL,
`access_token` text,
`refresh_token` text,
`account_id` varchar(50) DEFAULT NULL,
`expires` datetime DEFAULT NULL,
`scope` text,
`token_type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `apaleo_tokens_exp_pk` (`expires`)
)
COLLATE='utf8_general_ci'");
$db->exec("CREATE TABLE IF NOT EXISTS `leiwand_setup` (
`id` VARCHAR(36) NOT NULL,
`account_code` VARCHAR(10) NOT NULL,
`property_id` VARCHAR(10) NOT NULL,
`host` VARCHAR(150) NOT NULL,
`ll_token` VARCHAR(100) NOT NULL,
`active` TINYINT(1) NOT NULL DEFAULT 0,
`subscription_id` VARCHAR(50) DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'");
$db->exec("CREATE TABLE IF NOT EXISTS `leiwand_units` (
`id` VARCHAR(36) NOT NULL,
`account_id` VARCHAR(36) NOT NULL,
`property_id` VARCHAR(36) NOT NULL,
`room_id` VARCHAR(36) NOT NULL,
`active` TINYINT(1) NOT NULL DEFAULT 0,
`synced` TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'");
$db->exec("CREATE TABLE IF NOT EXISTS `reservations` (
`id` VARCHAR(100) NOT NULL,
`account_id` VARCHAR(50) NULL,
`property_id` VARCHAR(50) NULL,
`reservation_id` VARCHAR(50) NULL,
`qrcode_generated` TINYINT(1) NOT NULL DEFAULT 0,
`email_sent` DATETIME DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'");
$db->exec("CREATE TABLE IF NOT EXISTS `email_setup` (
`id` varchar(100) NOT NULL,
`account_id` varchar(50) DEFAULT NULL,
`SMTPSecure` varchar(10) DEFAULT NULL,
`SMTPAuth` tinyint(1) NOT NULL DEFAULT '0',
`Host` varchar(150) DEFAULT NULL,
`Port` int(11) DEFAULT '25',
`Username` varchar(50) DEFAULT NULL,
`Password` varchar(100) DEFAULT NULL,
`FromAddress` varchar(150) DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'");