xref: /webtrees/app/Schema/Migration0.php (revision 52550490b7095dd69811f3ec21ed5a3ca1a8968d)
13bfb94b0SGreg Roach<?php
23976b470SGreg Roach
33bfb94b0SGreg Roach/**
43bfb94b0SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
63bfb94b0SGreg Roach * This program is free software: you can redistribute it and/or modify
73bfb94b0SGreg Roach * it under the terms of the GNU General Public License as published by
83bfb94b0SGreg Roach * the Free Software Foundation, either version 3 of the License, or
93bfb94b0SGreg Roach * (at your option) any later version.
103bfb94b0SGreg Roach * This program is distributed in the hope that it will be useful,
113bfb94b0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
123bfb94b0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133bfb94b0SGreg Roach * GNU General Public License for more details.
143bfb94b0SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
163bfb94b0SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Schema;
2176692c8bSGreg Roach
226f4ec3caSGreg Roachuse Fisharebest\Webtrees\DB;
23c9beb871SGreg Roachuse Illuminate\Database\Schema\Blueprint;
243bfb94b0SGreg Roach
253bfb94b0SGreg Roach/**
2676692c8bSGreg Roach * Upgrade the database schema from version 0 (empty database) to version 1.
273bfb94b0SGreg Roach */
28c1010edaSGreg Roachclass Migration0 implements MigrationInterface
29c1010edaSGreg Roach{
30362be83aSGreg Roach    public function upgrade(): void
31c1010edaSGreg Roach    {
320b5fd0a6SGreg Roach        DB::schema()->create('gedcom', static function (Blueprint $table): void {
33c9beb871SGreg Roach            $table->integer('gedcom_id', true);
34c9beb871SGreg Roach            $table->string('gedcom_name', 255);
35c9beb871SGreg Roach            $table->integer('sort_order')->default(0);
363bfb94b0SGreg Roach
37c9beb871SGreg Roach            $table->unique('gedcom_name');
38c9beb871SGreg Roach            $table->index('sort_order');
39c9beb871SGreg Roach        });
403bfb94b0SGreg Roach
410b5fd0a6SGreg Roach        DB::schema()->create('site_setting', static function (Blueprint $table): void {
42c9beb871SGreg Roach            $table->string('setting_name', 32);
43c9beb871SGreg Roach            $table->string('setting_value', 2000);
44c9beb871SGreg Roach
45c9beb871SGreg Roach            $table->primary('setting_name');
46c9beb871SGreg Roach        });
47c9beb871SGreg Roach
480b5fd0a6SGreg Roach        DB::schema()->create('gedcom_setting', static function (Blueprint $table): void {
49c9beb871SGreg Roach            $table->integer('gedcom_id');
50c9beb871SGreg Roach            $table->string('setting_name', 32);
51c9beb871SGreg Roach            $table->string('setting_value', 255);
52c9beb871SGreg Roach
53c9beb871SGreg Roach            $table->primary(['gedcom_id', 'setting_name']);
54c9beb871SGreg Roach
55c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
56c9beb871SGreg Roach        });
57c9beb871SGreg Roach
580b5fd0a6SGreg Roach        DB::schema()->create('user', static function (Blueprint $table): void {
59c9beb871SGreg Roach            $table->integer('user_id', true);
60c9beb871SGreg Roach            $table->string('user_name', 32);
61c9beb871SGreg Roach            $table->string('real_name', 64);
62c9beb871SGreg Roach            $table->string('email', 64);
63c9beb871SGreg Roach            $table->string('password', 128);
64c9beb871SGreg Roach
65c9beb871SGreg Roach            $table->unique('user_name');
66c9beb871SGreg Roach            $table->unique('email');
67c9beb871SGreg Roach        });
68c9beb871SGreg Roach
690b5fd0a6SGreg Roach        DB::schema()->create('user_setting', static function (Blueprint $table): void {
70c9beb871SGreg Roach            $table->integer('user_id');
71c9beb871SGreg Roach            $table->string('setting_name', 32);
72c9beb871SGreg Roach            $table->string('setting_value', 255);
73c9beb871SGreg Roach
74c9beb871SGreg Roach            $table->primary(['user_id', 'setting_name']);
75c9beb871SGreg Roach
76c9beb871SGreg Roach            $table->foreign('user_id')->references('user_id')->on('user');
77c9beb871SGreg Roach        });
78c9beb871SGreg Roach
790b5fd0a6SGreg Roach        DB::schema()->create('user_gedcom_setting', static function (Blueprint $table): void {
80c9beb871SGreg Roach            $table->integer('user_id');
81c9beb871SGreg Roach            $table->integer('gedcom_id');
82c9beb871SGreg Roach            $table->string('setting_name', 32);
83c9beb871SGreg Roach            $table->string('setting_value', 255);
84c9beb871SGreg Roach
8509331e47SGreg Roach            // Default constraint names are too long for MySQL.
86*211018abSGreg Roach            $key = DB::prefix($table->getTable() . '_primary');
8709331e47SGreg Roach
8809331e47SGreg Roach            $table->primary(['user_id', 'gedcom_id', 'setting_name'], $key);
89c9beb871SGreg Roach            $table->index('gedcom_id');
90c9beb871SGreg Roach
91c9beb871SGreg Roach            $table->foreign('user_id')->references('user_id')->on('user');
92c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
93c9beb871SGreg Roach        });
94c9beb871SGreg Roach
950b5fd0a6SGreg Roach        DB::schema()->create('log', static function (Blueprint $table): void {
96c9beb871SGreg Roach            $table->integer('log_id', true);
97c9beb871SGreg Roach            $table->timestamp('log_time')->useCurrent();
98c9beb871SGreg Roach            $table->enum('log_type', ['auth', 'config', 'debug', 'edit', 'error', 'media', 'search']);
99c9beb871SGreg Roach            $table->longText('log_message');
100c9beb871SGreg Roach            $table->ipAddress('ip_address');
101c9beb871SGreg Roach            $table->integer('user_id')->nullable();
102c9beb871SGreg Roach            $table->integer('gedcom_id')->nullable();
103c9beb871SGreg Roach
104c9beb871SGreg Roach            $table->index('log_time');
105c9beb871SGreg Roach            $table->index('log_type');
106c9beb871SGreg Roach            $table->index('ip_address');
107c9beb871SGreg Roach            $table->index('user_id');
108c9beb871SGreg Roach            $table->index('gedcom_id');
109c9beb871SGreg Roach
110c9beb871SGreg Roach            $table->foreign('user_id')->references('user_id')->on('user');
111c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
112c9beb871SGreg Roach        });
113c9beb871SGreg Roach
1140b5fd0a6SGreg Roach        DB::schema()->create('change', static function (Blueprint $table): void {
115c9beb871SGreg Roach            $table->integer('change_id', true);
116c9beb871SGreg Roach            $table->timestamp('change_time')->useCurrent();
117c9beb871SGreg Roach            $table->enum('status', ['accepted', 'pending', 'rejected'])->default('pending');
118c9beb871SGreg Roach            $table->integer('gedcom_id');
119c9beb871SGreg Roach            $table->string('xref', 20);
120c9beb871SGreg Roach            $table->longText('old_gedcom');
121c9beb871SGreg Roach            $table->longText('new_gedcom');
122c9beb871SGreg Roach            $table->integer('user_id');
123c9beb871SGreg Roach
124c9beb871SGreg Roach            $table->index(['gedcom_id', 'status', 'xref']);
125c9beb871SGreg Roach            $table->index('user_id');
126c9beb871SGreg Roach
127c9beb871SGreg Roach            $table->foreign('user_id')->references('user_id')->on('user');
128c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
129c9beb871SGreg Roach        });
130c9beb871SGreg Roach
1310b5fd0a6SGreg Roach        DB::schema()->create('message', static function (Blueprint $table): void {
132c9beb871SGreg Roach            $table->integer('message_id', true);
133c9beb871SGreg Roach            $table->string('sender', 64);
134c9beb871SGreg Roach            $table->ipAddress('ip_address');
135c9beb871SGreg Roach            $table->integer('user_id');
136c9beb871SGreg Roach            $table->string('subject', 255);
137c9beb871SGreg Roach            $table->longText('body');
138c9beb871SGreg Roach            $table->timestamp('created')->useCurrent();
139c9beb871SGreg Roach
140c9beb871SGreg Roach            $table->index('user_id');
141c9beb871SGreg Roach
142c9beb871SGreg Roach            $table->foreign('user_id')->references('user_id')->on('user');
143c9beb871SGreg Roach        });
144c9beb871SGreg Roach
1450b5fd0a6SGreg Roach        DB::schema()->create('default_resn', static function (Blueprint $table): void {
146c9beb871SGreg Roach            $table->integer('default_resn_id', true);
147c9beb871SGreg Roach            $table->integer('gedcom_id');
148c9beb871SGreg Roach            $table->string('xref', 20)->nullable();
149c9beb871SGreg Roach            $table->string('tag_type', 15)->nullable();
150c9beb871SGreg Roach            $table->enum('resn', ['none', 'privacy', 'confidential', 'hidden']);
151c9beb871SGreg Roach            $table->string('comment', 255)->nullable();
152c9beb871SGreg Roach            $table->timestamp('updated')->useCurrent();
153c9beb871SGreg Roach
154c9beb871SGreg Roach            $table->unique(['gedcom_id', 'xref', 'tag_type']);
155c9beb871SGreg Roach
156c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
157c9beb871SGreg Roach        });
158c9beb871SGreg Roach
1590b5fd0a6SGreg Roach        DB::schema()->create('individuals', static function (Blueprint $table): void {
160c9beb871SGreg Roach            $table->string('i_id', 20);
161c9beb871SGreg Roach            $table->integer('i_file');
162c9beb871SGreg Roach            $table->string('i_rin', 20);
163c9beb871SGreg Roach            $table->enum('i_sex', ['U', 'M', 'F']);
164c9beb871SGreg Roach            $table->longText('i_gedcom');
165c9beb871SGreg Roach
166c9beb871SGreg Roach            $table->primary(['i_id', 'i_file']);
167c9beb871SGreg Roach            $table->unique(['i_file', 'i_id']);
168c9beb871SGreg Roach        });
169c9beb871SGreg Roach
1700b5fd0a6SGreg Roach        DB::schema()->create('families', static function (Blueprint $table): void {
171c9beb871SGreg Roach            $table->string('f_id', 20);
172c9beb871SGreg Roach            $table->integer('f_file');
173c9beb871SGreg Roach            $table->string('f_husb', 20)->nullable();
174c9beb871SGreg Roach            $table->string('f_wife', 20)->nullable();
175c9beb871SGreg Roach            $table->longText('f_gedcom');
176c9beb871SGreg Roach            $table->integer('f_numchil');
177c9beb871SGreg Roach
178c9beb871SGreg Roach            $table->primary(['f_id', 'f_file']);
179c9beb871SGreg Roach            $table->unique(['f_file', 'f_id']);
180c9beb871SGreg Roach            $table->index('f_husb');
181c9beb871SGreg Roach            $table->index('f_wife');
182c9beb871SGreg Roach        });
183c9beb871SGreg Roach
1840b5fd0a6SGreg Roach        DB::schema()->create('places', static function (Blueprint $table): void {
185c9beb871SGreg Roach            $table->integer('p_id', true);
186c9beb871SGreg Roach            $table->string('p_place', 150);
187c9beb871SGreg Roach            $table->integer('p_parent_id')->nullable();
188c9beb871SGreg Roach            $table->integer('p_file');
189c9beb871SGreg Roach            $table->longText('p_std_soundex')->nullable();
190c9beb871SGreg Roach            $table->longText('p_dm_soundex')->nullable();
191c9beb871SGreg Roach
192c9beb871SGreg Roach            $table->index(['p_file', 'p_place']);
193c9beb871SGreg Roach            $table->unique(['p_parent_id', 'p_file', 'p_place']);
194c9beb871SGreg Roach        });
195c9beb871SGreg Roach
1960b5fd0a6SGreg Roach        DB::schema()->create('placelinks', static function (Blueprint $table): void {
197c9beb871SGreg Roach            $table->integer('pl_p_id');
198c9beb871SGreg Roach            $table->string('pl_gid', 20);
199c9beb871SGreg Roach            $table->integer('pl_file');
200c9beb871SGreg Roach
201c9beb871SGreg Roach            $table->primary(['pl_p_id', 'pl_gid', 'pl_file']);
202c9beb871SGreg Roach            $table->index('pl_p_id');
203c9beb871SGreg Roach            $table->index('pl_gid');
204c9beb871SGreg Roach            $table->index('pl_file');
205c9beb871SGreg Roach        });
206c9beb871SGreg Roach
2070b5fd0a6SGreg Roach        DB::schema()->create('dates', static function (Blueprint $table): void {
208c9beb871SGreg Roach            $table->tinyInteger('d_day');
209c9beb871SGreg Roach            $table->char('d_month', 5)->nullable();
210c9beb871SGreg Roach            $table->tinyInteger('d_mon');
211c9beb871SGreg Roach            $table->smallInteger('d_year');
212c9beb871SGreg Roach            $table->mediumInteger('d_julianday1');
213c9beb871SGreg Roach            $table->mediumInteger('d_julianday2');
214c9beb871SGreg Roach            $table->string('d_fact', 15);
215c9beb871SGreg Roach            $table->string('d_gid', 20);
216c9beb871SGreg Roach            $table->integer('d_file');
217c9beb871SGreg Roach            $table->enum('d_type', ['@#DGREGORIAN@', '@#DJULIAN@', '@#DHEBREW@', '@#DFRENCH R@', '@#DHIJRI@', '@#DROMAN@', '@#DJALALI@']);
218c9beb871SGreg Roach
219c9beb871SGreg Roach            $table->index('d_day');
220c9beb871SGreg Roach            $table->index('d_month');
221c9beb871SGreg Roach            $table->index('d_mon');
222c9beb871SGreg Roach            $table->index('d_year');
223c9beb871SGreg Roach            $table->index('d_julianday1');
224c9beb871SGreg Roach            $table->index('d_julianday2');
225c9beb871SGreg Roach            $table->index('d_gid');
226c9beb871SGreg Roach            $table->index('d_file');
227c9beb871SGreg Roach            $table->index('d_type');
228c9beb871SGreg Roach            $table->index(['d_fact', 'd_gid']);
229c9beb871SGreg Roach        });
230c9beb871SGreg Roach
2310b5fd0a6SGreg Roach        DB::schema()->create('media', static function (Blueprint $table): void {
232c9beb871SGreg Roach            $table->string('m_id', 20);
233c9beb871SGreg Roach            $table->string('m_ext', 6)->nullable();
234c9beb871SGreg Roach            $table->string('m_type', 20)->nullable();
235bb308685SGreg Roach            $table->string('m_titl', 248)->nullable();
236bb308685SGreg Roach            $table->string('m_filename', 248)->nullable();
237c9beb871SGreg Roach            $table->integer('m_file');
238c9beb871SGreg Roach            $table->longText('m_gedcom')->nullable();
239c9beb871SGreg Roach
240c9beb871SGreg Roach            $table->primary(['m_file', 'm_id']);
241c9beb871SGreg Roach            $table->unique(['m_id', 'm_file']);
242115a8bddSGreg Roach            // Originally, this migration created an index on m_ext and m_type,
243115a8bddSGreg Roach            // but we drop those columns in migration 37.
244c9beb871SGreg Roach        });
245c9beb871SGreg Roach
2460b5fd0a6SGreg Roach        DB::schema()->create('next_id', static function (Blueprint $table): void {
247c9beb871SGreg Roach            $table->integer('gedcom_id');
248c9beb871SGreg Roach            $table->string('record_type', 15);
249c9beb871SGreg Roach            $table->decimal('next_id', 20, 0);
250c9beb871SGreg Roach
251c9beb871SGreg Roach            $table->primary(['gedcom_id', 'record_type']);
252c9beb871SGreg Roach
253c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
254c9beb871SGreg Roach        });
255c9beb871SGreg Roach
2560b5fd0a6SGreg Roach        DB::schema()->create('other', static function (Blueprint $table): void {
257c9beb871SGreg Roach            $table->string('o_id', 20);
258c9beb871SGreg Roach            $table->integer('o_file');
259c9beb871SGreg Roach            $table->string('o_type', 15);
260c9beb871SGreg Roach            $table->longText('o_gedcom');
261c9beb871SGreg Roach
262c9beb871SGreg Roach            $table->primary(['o_id', 'o_file']);
263c9beb871SGreg Roach            $table->unique(['o_file', 'o_id']);
264c9beb871SGreg Roach        });
265c9beb871SGreg Roach
2660b5fd0a6SGreg Roach        DB::schema()->create('sources', static function (Blueprint $table): void {
267c9beb871SGreg Roach            $table->string('s_id', 20);
268c9beb871SGreg Roach            $table->integer('s_file');
269c9beb871SGreg Roach            $table->string('s_name', 255);
270c9beb871SGreg Roach            $table->longText('s_gedcom');
271c9beb871SGreg Roach
272c9beb871SGreg Roach            $table->primary(['s_id', 's_file']);
273c9beb871SGreg Roach            $table->unique(['s_file', 's_id']);
274c9beb871SGreg Roach            $table->index('s_name');
275c9beb871SGreg Roach        });
276c9beb871SGreg Roach
2770b5fd0a6SGreg Roach        DB::schema()->create('link', static function (Blueprint $table): void {
278c9beb871SGreg Roach            $table->integer('l_file');
279c9beb871SGreg Roach            $table->string('l_from', 20);
280c9beb871SGreg Roach            $table->string('l_type', 15);
281c9beb871SGreg Roach            $table->string('l_to', 20);
282c9beb871SGreg Roach
283c9beb871SGreg Roach            $table->primary(['l_from', 'l_file', 'l_type', 'l_to']);
284c9beb871SGreg Roach            $table->unique(['l_to', 'l_file', 'l_type', 'l_from']);
285c9beb871SGreg Roach        });
286c9beb871SGreg Roach
2870b5fd0a6SGreg Roach        DB::schema()->create('name', static function (Blueprint $table): void {
288c9beb871SGreg Roach            $table->integer('n_file');
289c9beb871SGreg Roach            $table->string('n_id', 20);
290c9beb871SGreg Roach            $table->integer('n_num');
291c9beb871SGreg Roach            $table->string('n_type', 15);
292c9beb871SGreg Roach            $table->string('n_sort', 255);
293c9beb871SGreg Roach            $table->string('n_full', 255);
294c9beb871SGreg Roach            $table->string('n_surname', 255)->nullable();
295c9beb871SGreg Roach            $table->string('n_surn', 255)->nullable();
296c9beb871SGreg Roach            $table->string('n_givn', 255)->nullable();
297c9beb871SGreg Roach            $table->string('n_soundex_givn_std', 255)->nullable();
298c9beb871SGreg Roach            $table->string('n_soundex_surn_std', 255)->nullable();
299c9beb871SGreg Roach            $table->string('n_soundex_givn_dm', 255)->nullable();
300c9beb871SGreg Roach            $table->string('n_soundex_surn_dm', 255)->nullable();
301c9beb871SGreg Roach
302c9beb871SGreg Roach            $table->primary(['n_id', 'n_file', 'n_num']);
303c9beb871SGreg Roach            $table->index(['n_full', 'n_id', 'n_file']);
304c9beb871SGreg Roach            $table->index(['n_surn', 'n_file', 'n_type', 'n_id']);
305c9beb871SGreg Roach            $table->index(['n_givn', 'n_file', 'n_type', 'n_id']);
306c9beb871SGreg Roach        });
307c9beb871SGreg Roach
3080b5fd0a6SGreg Roach        DB::schema()->create('module', static function (Blueprint $table): void {
309c9beb871SGreg Roach            $table->string('module_name', 32);
310c9beb871SGreg Roach            $table->enum('status', ['enabled', 'disabled'])->default('enabled');
311c9beb871SGreg Roach            $table->integer('tab_order')->nullable();
312c9beb871SGreg Roach            $table->integer('menu_order')->nullable();
313c9beb871SGreg Roach            $table->integer('sidebar_order')->nullable();
314c9beb871SGreg Roach
315c9beb871SGreg Roach            $table->primary('module_name');
316c9beb871SGreg Roach        });
317c9beb871SGreg Roach
3180b5fd0a6SGreg Roach        DB::schema()->create('module_setting', static function (Blueprint $table): void {
319c9beb871SGreg Roach            $table->string('module_name', 32);
320c9beb871SGreg Roach            $table->string('setting_name', 32);
321c9beb871SGreg Roach            $table->longText('setting_value');
322c9beb871SGreg Roach
323c9beb871SGreg Roach            $table->primary(['module_name', 'setting_name']);
324c9beb871SGreg Roach
325c9beb871SGreg Roach            $table->foreign('module_name')->references('module_name')->on('module');
326c9beb871SGreg Roach        });
327c9beb871SGreg Roach
3280b5fd0a6SGreg Roach        DB::schema()->create('module_privacy', static function (Blueprint $table): void {
329c9beb871SGreg Roach            $table->string('module_name', 32);
330c9beb871SGreg Roach            $table->integer('gedcom_id');
331c9beb871SGreg Roach            $table->enum('component', ['block', 'chart', 'menu', 'report', 'sidebar', 'tab', 'theme']);
332c9beb871SGreg Roach            $table->tinyInteger('access_level');
333c9beb871SGreg Roach
33409331e47SGreg Roach            // Default constraint names are too long for MySQL.
335*211018abSGreg Roach            $key0 = DB::prefix($table->getTable() . '_primary');
336*211018abSGreg Roach            $key1 = DB::prefix($table->getTable() . '_ix1');
33709331e47SGreg Roach
33809331e47SGreg Roach            $table->primary(['module_name', 'gedcom_id', 'component'], $key0);
33909331e47SGreg Roach            $table->unique(['gedcom_id', 'module_name', 'component'], $key1);
340c9beb871SGreg Roach
341c9beb871SGreg Roach            $table->foreign('module_name')->references('module_name')->on('module');
342c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
343c9beb871SGreg Roach        });
344c9beb871SGreg Roach
3450b5fd0a6SGreg Roach        DB::schema()->create('block', static function (Blueprint $table): void {
346c9beb871SGreg Roach            $table->integer('block_id', true);
347c9beb871SGreg Roach            $table->integer('gedcom_id')->nullable();
348c9beb871SGreg Roach            $table->integer('user_id')->nullable();
349c9beb871SGreg Roach            $table->string('xref', 20)->nullable();
350c9beb871SGreg Roach            $table->enum('location', ['main', 'side'])->nullable();
351c9beb871SGreg Roach            $table->integer('block_order');
352c9beb871SGreg Roach            $table->string('module_name', 32);
353c9beb871SGreg Roach
354c9beb871SGreg Roach            $table->index('module_name');
355c9beb871SGreg Roach            $table->index('gedcom_id');
356c9beb871SGreg Roach            $table->index('user_id');
357c9beb871SGreg Roach
358c9beb871SGreg Roach            $table->foreign('module_name')->references('module_name')->on('module');
359c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
360c9beb871SGreg Roach            $table->foreign('user_id')->references('user_id')->on('user');
361c9beb871SGreg Roach        });
362c9beb871SGreg Roach
3630b5fd0a6SGreg Roach        DB::schema()->create('block_setting', static function (Blueprint $table): void {
364c9beb871SGreg Roach            $table->integer('block_id');
365c9beb871SGreg Roach            $table->string('setting_name', 32);
366c9beb871SGreg Roach            $table->longText('setting_value');
367c9beb871SGreg Roach
368c9beb871SGreg Roach            $table->primary(['block_id', 'setting_name']);
369c9beb871SGreg Roach
370c9beb871SGreg Roach            $table->foreign('block_id')->references('block_id')->on('block');
371c9beb871SGreg Roach        });
372c9beb871SGreg Roach
3730b5fd0a6SGreg Roach        DB::schema()->create('hit_counter', static function (Blueprint $table): void {
374c9beb871SGreg Roach            $table->integer('gedcom_id');
375c9beb871SGreg Roach            $table->string('page_name', 32);
376c9beb871SGreg Roach            $table->string('page_parameter', 32);
377c9beb871SGreg Roach            $table->integer('page_count');
378c9beb871SGreg Roach
37909331e47SGreg Roach            // Default constraint names are too long for MySQL.
380*211018abSGreg Roach            $key = DB::prefix($table->getTable() . '_primary');
38109331e47SGreg Roach
38209331e47SGreg Roach            $table->primary(['gedcom_id', 'page_name', 'page_parameter'], $key);
383c9beb871SGreg Roach
384c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
385c9beb871SGreg Roach        });
386c9beb871SGreg Roach
3870b5fd0a6SGreg Roach        DB::schema()->create('session', static function (Blueprint $table): void {
38876c252f0SGreg Roach            $table->string('session_id', 256);
389c9beb871SGreg Roach            $table->timestamp('session_time')->useCurrent();
390c9beb871SGreg Roach            $table->integer('user_id');
391c9beb871SGreg Roach            $table->ipAddress('ip_address');
392736b8b72SGreg Roach            $table->longText('session_data');
393c9beb871SGreg Roach
394c9beb871SGreg Roach            $table->primary('session_id');
395c9beb871SGreg Roach            $table->index('session_time');
396c9beb871SGreg Roach            $table->index(['user_id', 'ip_address']);
397c9beb871SGreg Roach        });
398c9beb871SGreg Roach
3990b5fd0a6SGreg Roach        DB::schema()->create('gedcom_chunk', static function (Blueprint $table): void {
400c9beb871SGreg Roach            $table->integer('gedcom_chunk_id', true);
401c9beb871SGreg Roach            $table->integer('gedcom_id');
402736b8b72SGreg Roach            $table->longText('chunk_data');
403c9beb871SGreg Roach            $table->boolean('imported')->default(0);
404c9beb871SGreg Roach
405c9beb871SGreg Roach            $table->index(['gedcom_id', 'imported']);
406c9beb871SGreg Roach
407c9beb871SGreg Roach            $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom');
408c9beb871SGreg Roach        });
4093bfb94b0SGreg Roach    }
4103bfb94b0SGreg Roach}
411