mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 13:03:41 +02:00
feat: version control database seeds (#29)
This PR replaces the database files from Release with VCS in git Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/29 Co-authored-by: vlw <victor@vlw.se> Co-committed-by: vlw <victor@vlw.se>
This commit is contained in:
parent
5c7c9d2d3a
commit
f76962e2ac
3 changed files with 382 additions and 2 deletions
|
@ -41,9 +41,10 @@ cd /var/www/vlw.se
|
|||
```
|
||||
|
||||
## 4. Import the database templates
|
||||
There's are two SQL files that you can download from the releases page that has a snapshot of the MariaDB databases I use on my live website. The snapshot data for the website databse is not guaranteed to be up to date; but the database structure will be. Download and import these files into two existing databases. One for the website data, and the other has the Reflect API configurations.
|
||||
There's are two SQL files in [`/src/Database/Seeds/`](https://codeberg.org/vlw/vlw.se/src/branch/master/src/Database/Seeds) that you can use to initialize the two databases required for this website.
|
||||
|
||||
- [Download SQL-snapshots](https://codeberg.org/vlw/vlw.se/releases)
|
||||
- `vlw` - This database has the website data and should be added to the `db` variable under `server_database` in `/.env.ini`
|
||||
- `vlw_reflect` - This is the Reflect database that has all the endpoints pre-configured. You'll have to add your own ACL rules.
|
||||
|
||||
## 5. Set environment variables
|
||||
Make a copy of the `.env.example.ini` file called `.env.ini` from the root directory of the repo. There are a few parameters you can change here but the required ones are the following:
|
||||
|
|
282
src/Database/Seeds/vlw.sql
Normal file
282
src/Database/Seeds/vlw.sql
Normal file
|
@ -0,0 +1,282 @@
|
|||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
|
||||
CREATE TABLE `about_languages` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
`bytes` int(10) UNSIGNED NOT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `coffee` (
|
||||
`id` int(32) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `after_coffee_insert` AFTER INSERT ON `coffee` FOR EACH ROW BEGIN
|
||||
DECLARE count_recent INT;
|
||||
DECLARE count_average INT;
|
||||
|
||||
-- Clear the stats table --
|
||||
DELETE FROM coffee_stats;
|
||||
|
||||
-- Count the number of rows with timestamp less than 7 days ago
|
||||
SELECT COUNT(*) INTO count_recent
|
||||
FROM coffee
|
||||
WHERE id > UNIX_TIMESTAMP(NOW() - INTERVAL 7 DAY);
|
||||
|
||||
-- Calculate the average count of rows for each week
|
||||
SELECT COUNT(*) / COUNT(DISTINCT YEAR(FROM_UNIXTIME(id)), WEEK(FROM_UNIXTIME(id)))
|
||||
INTO count_average
|
||||
FROM coffee;
|
||||
|
||||
-- Insert the count into the stats table
|
||||
INSERT INTO coffee_stats (count_week, count_week_average) VALUES (count_recent, count_average);
|
||||
END
|
||||
$$
|
||||
DELIMITER ;
|
||||
|
||||
CREATE TABLE `coffee_stats` (
|
||||
`count_week` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`count_week_average` smallint(5) UNSIGNED NOT NULL DEFAULT 0
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `messages` (
|
||||
`email` varchar(255) DEFAULT NULL,
|
||||
`message` text NOT NULL,
|
||||
`timestamp_created` int(32) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `search` (
|
||||
`query` varchar(2048) NOT NULL,
|
||||
`id` char(10) NOT NULL,
|
||||
`title` varchar(2048) DEFAULT NULL,
|
||||
`summary` varchar(2048) NOT NULL,
|
||||
`category` enum('WORK') DEFAULT NULL,
|
||||
`href` varchar(2048) DEFAULT NULL
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `work` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`summary` text NOT NULL,
|
||||
`created` date NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
INSERT INTO `work` (`id`, `title`, `summary`, `created`) VALUES
|
||||
('deltaco/asyncapp', 'Campaign pages for Deltaco', 'From design mock-ups created by the SweDeltaco marketing team, I built various web pages for campagins and special events for the nordic IT-distributor\'s website using a custom content injection framework for SharePoint that would later inspire my other project, Vegvisir.', '2020-10-18'),
|
||||
('deltaco/distit', 'WordPress modules for DistIT', 'Maintenance of a web server for DistIT\'s WordPress website. DistIT is the parent company of SweDeltaco where I was employed for a few years. In addition to server maintenance, I also wrote a few custom WordPress modules for the site, and helped update DistIT\'s custom WordPress theme with new content when required.', '2021-01-21'),
|
||||
('deltaco/e-charge', 'Product guide for Deltaco E-Charge', 'Front- and back-end for a product configurator from a design mock-up created by one of SweDeltaco\'s graphics designers. The configurator was for Deltaco\'s \"E-charge\"-line of EV-charger products.', '2021-04-06'),
|
||||
('deltaco/office', 'Product guide for Deltaco Office', 'Product configurator of my own design for Deltaco\'s \"Deltaco Office\"-line of products. The configurator is open source and was implemented by various big-name brands of resellers across the nordics.', '2020-09-04'),
|
||||
('deltaco/pdf-generator', 'PDF datasheet generator for Deltaco', 'Custom PDF generator for SharePoint 2013', '2020-09-04'),
|
||||
('deltaco/reseller-form', 'Customer registration form for Deltaco', 'Custom web form which integrated with existing back-end infrastructure to handle new authorized resellers of Deltaco\'s assortment.', '2020-08-04'),
|
||||
('icellate/genemate', 'Website for GeneMate by iCellate Medical', 'Together with copy written by the marketing team at iCellate, and a new brand new appearance for the company, I helped design a new website and underlying systems for their GeneMate product.', '2022-11-07'),
|
||||
('icellate/website', 'Website for iCellate Medical', 'Together with the iCellate team, I created a new front-end for the biopharma startup using my Vegvisir framework as the foundation.', '2023-04-19'),
|
||||
('itg/lan', 'Reservation website for ITG-Sundbyberg', 'Redesign of IT-Gymnasiet Sundbyberg\'s seat reservation system, tournament registration, and information website for their yearly LAN events.', '2014-09-02'),
|
||||
('itg/upload', 'Web project upload for ITG-Sundbyberg', 'Special school assignment for my Web programming course at IT-Gymnasiet Sundbyberg', '2014-06-11'),
|
||||
('vlw/camera-obscura', 'cameraobscura.gr', 'Portable front-end website for Camera Obscura GR', '2018-04-25'),
|
||||
('vlw/collage', 'vlw/collage', 'Create an image where each \"pixel\" is a smaller image of similar color to the original image.', '2021-03-21'),
|
||||
('vlw/dediprison', 'DediPrison', 'Public Minecraft server project together with a friend that had around 20-30 active monthly players.', '2015-10-13'),
|
||||
('vlw/disneyplus-pip', 'vlw/disneyplus-pip', 'Enable (or rather disable Disney\'s block of) picture-in-picture on disneyplus.com for Chrome.', '2021-01-31'),
|
||||
('vlw/edkb', 'vlw/edkb', 'Printable keyboard overlay for some controls in Elite Dangerous.', '2021-03-18'),
|
||||
('vlw/elevent', 'vlw/elevent', 'A small npm module that is intended to add more control over event listeners on HTMLElements with JavaScript. Kind of a superset of addEventListener.', '2024-11-11'),
|
||||
('vlw/eyeart', 'eyeart.me', 'Website designed by me for the Greek/Swedish photographer, eyeart. The website features albums, a blog, and news pages.', '2014-03-02'),
|
||||
('vlw/ion-musik', 'Website for ION Musik', 'Portable front-end website for Greek musican, ION Musik.', '2015-06-11'),
|
||||
('vlw/labylib', 'LabyLib', 'Library for controlling LabyMod cosmetics programmatically in Python.', '2020-11-11'),
|
||||
('vlw/labylib-animated-cape', 'vlw/labylib-animated-cape', 'Minecraft cosmetics scripts for my labylib library that cycles between a set of Labymod capes, creating a (slow) animation.', '2020-11-15'),
|
||||
('vlw/labylib-chattycape', 'vlw/labylib-chattycape', 'Minecraft cosmetics update script for my labylib library that drew a picture of the last person who sent something in chat.', '2020-11-15'),
|
||||
('vlw/misskey-microblogger', 'vlw/misskey-microblogger', 'Bot program for Misskey (and compatible forks) that simulates a whole community of independent microbloggers with posts, reactions, and replies. Users have unique personalities, friend groups, partners, and even enemies to whom they will act and respond differently to, sometimes not at all.', '2024-11-09'),
|
||||
('vlw/monkeydo', 'MonkeyDo', 'A multi-threaded keyframe animation library for JavaScript.', '2021-10-08'),
|
||||
('vlw/php-age', 'vlw/php-age', 'Asymmetric encryption and decryption of files from PHP with this wrapper for the age command line tool.', '2023-08-22'),
|
||||
('vlw/php-functionflags', 'vlw/php-functionflags', '', '2023-03-16'),
|
||||
('vlw/php-globalsnapshot', 'vlw/php-globalsnapshot', '\"Proxy\" PHP superglobals by taking snapshots of current values. The snapshotted state can then be restored at any point.', '2024-04-18'),
|
||||
('vlw/php-mime-types', 'vlw/php-mime-types', 'Library for resolving a RFC 4288-compatible MIME-type list. After loading a list, files on disk can be queried for types and extensions.', '2024-10-27'),
|
||||
('vlw/php-mysql', 'vlw/php-mysql', 'Yet another abstraction library for the php-mysql extension. For this library, I was willing to sacrifice most of MySQL\'s flexibility that comes with string interpolation in favor of method chaining that adheres to an SQL-like syntax. For simple DML operations I think it\'s pretty intuitive.', '2023-04-08'),
|
||||
('vlw/php-sqlite', 'vlw/php-sqlite', 'Abstraction library for common DML queries on an SQLite database with php-sqlite3.', '2023-04-18'),
|
||||
('vlw/php-xenum', 'vlw/php-xenum', 'Adds a variety of missing quality-of-life methods to PHP 8.0 Enums.', '2023-06-12'),
|
||||
('vlw/pysheeter', 'Pysheeter', 'Sprite sheet generator for PNGs in Python.', '2020-11-20'),
|
||||
('vlw/reflect', 'Reflect', 'A weird framework for building REST APIs in PHP with focus on native internal request routing and proxying.', '2022-11-18'),
|
||||
('vlw/stadia-avatar', 'vlw/stadia-avatar', '', '2021-02-03'),
|
||||
('vlw/still-alive', 'vlw/still-alive', '', '2021-10-12'),
|
||||
('vlw/vegvisir', 'Vegvisir', 'Web navigation framework for PHP websites that does on the fly MPA-to-SPA routing between pages on the [open] web seas.', '2022-11-26'),
|
||||
('vlw/vlw.se', 'vlw.se', 'Can I put my own website here, is that cheating? Maybe, but I think this site counts as the most important thing I\'ve personally created. I\'ve only used my own libraries and frameworks to create this website, so it kind of works as a live demonstration of many of my web projects bundled together.', '2023-06-13');
|
||||
|
||||
CREATE TABLE `work_actions` (
|
||||
`ref_work_id` varchar(255) NOT NULL,
|
||||
`icon_prepended` varchar(255) DEFAULT NULL,
|
||||
`icon_appended` varchar(255) DEFAULT NULL,
|
||||
`order_idx` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`display_text` varchar(255) NOT NULL,
|
||||
`href` varchar(255) DEFAULT NULL,
|
||||
`class_list` varchar(255) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
INSERT INTO `work_actions` (`ref_work_id`, `icon_prepended`, `icon_appended`, `order_idx`, `display_text`, `href`, `class_list`) VALUES
|
||||
('vlw/collage', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/collage', NULL),
|
||||
('vlw/disneyplus-pip', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/disneyplus-pip', NULL),
|
||||
('vlw/edkb', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/edkb', NULL),
|
||||
('vlw/labylib', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/labylib', NULL),
|
||||
('vlw/monkeydo', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/monkeydo', NULL),
|
||||
('vlw/php-age', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/php-age', NULL),
|
||||
('vlw/php-mysql', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/php-mysql', NULL),
|
||||
('vlw/php-xenum', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/php-xenum', NULL),
|
||||
('vlw/pysheeter', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/pysheeter', NULL),
|
||||
('vlw/vlw.se', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/vlw.se', NULL),
|
||||
('vlw/elevent', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/elevent', NULL),
|
||||
('vlw/misskey-microblogger', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/misskey-microblogger', ''),
|
||||
('vlw/php-mime-types', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/php-mime-types', NULL),
|
||||
('vlw/php-globalsnapshot', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/php-globalsnapshot', NULL),
|
||||
('vlw/php-sqlite', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/php-sqlite', NULL),
|
||||
('vlw/php-functionflags', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/functionflags', NULL),
|
||||
('vlw/still-alive', 'codeberg.svg', NULL, 0, 'view source', 'https://codeberg.org/vlw/still-alive', NULL),
|
||||
('vlw/still-alive', 'star.svg', NULL, 0, 'open demo', 'https://victorwesterlund.github.io/still-alive/', NULL);
|
||||
|
||||
CREATE TABLE `work_tags` (
|
||||
`ref_work_id` varchar(255) NOT NULL,
|
||||
`label` enum('VLW','RELEASE','WEBSITE','REPO') NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
INSERT INTO `work_tags` (`ref_work_id`, `label`) VALUES
|
||||
('vlw/eyeart', 'WEBSITE'),
|
||||
('itg/upload', 'WEBSITE'),
|
||||
('itg/lan', 'WEBSITE'),
|
||||
('vlw/dediprison', 'VLW'),
|
||||
('vlw/dediprison', 'WEBSITE'),
|
||||
('vlw/ion-musik', 'WEBSITE'),
|
||||
('vlw/camera-obscura', 'WEBSITE'),
|
||||
('deltaco/asyncapp', 'REPO'),
|
||||
('deltaco/reseller-form', 'WEBSITE'),
|
||||
('deltaco/pdf-generator', 'REPO'),
|
||||
('deltaco/office', 'WEBSITE'),
|
||||
('deltaco/distit', 'WEBSITE'),
|
||||
('deltaco/e-charge', 'WEBSITE'),
|
||||
('vlw/labylib', 'VLW'),
|
||||
('vlw/labylib', 'REPO'),
|
||||
('vlw/edkb', 'VLW'),
|
||||
('vlw/collage', 'VLW'),
|
||||
('vlw/collage', 'REPO'),
|
||||
('vlw/monkeydo', 'VLW'),
|
||||
('vlw/monkeydo', 'REPO'),
|
||||
('vlw/disneyplus-pip', 'VLW'),
|
||||
('vlw/disneyplus-pip', 'REPO'),
|
||||
('vlw/php-mysql', 'VLW'),
|
||||
('vlw/php-mysql', 'REPO'),
|
||||
('vlw/pysheeter', 'VLW'),
|
||||
('vlw/pysheeter', 'REPO'),
|
||||
('vlw/php-age', 'VLW'),
|
||||
('vlw/php-age', 'REPO'),
|
||||
('vlw/php-xenum', 'VLW'),
|
||||
('vlw/php-xenum', 'REPO'),
|
||||
('vlw/reflect', 'VLW'),
|
||||
('vlw/reflect', 'REPO'),
|
||||
('vlw/vegvisir', 'VLW'),
|
||||
('vlw/vegvisir', 'REPO'),
|
||||
('icellate/website', 'WEBSITE'),
|
||||
('icellate/genemate', 'WEBSITE'),
|
||||
('vlw/elevent', 'VLW'),
|
||||
('vlw/elevent', 'REPO'),
|
||||
('vlw/misskey-microblogger', 'VLW'),
|
||||
('vlw/misskey-microblogger', 'REPO'),
|
||||
('vlw/php-mime-types', 'VLW'),
|
||||
('vlw/php-mime-types', 'REPO'),
|
||||
('vlw/php-globalsnapshot', 'VLW'),
|
||||
('vlw/php-globalsnapshot', 'REPO'),
|
||||
('vlw/php-sqlite', 'VLW'),
|
||||
('vlw/php-sqlite', 'REPO'),
|
||||
('vlw/php-functionflags', 'VLW'),
|
||||
('vlw/php-functionflags', 'REPO'),
|
||||
('vlw/still-alive', 'VLW'),
|
||||
('vlw/still-alive', 'WEBSITE'),
|
||||
('vlw/stadia-avatar', 'VLW'),
|
||||
('vlw/stadia-avatar', 'REPO'),
|
||||
('vlw/labylib-chattycape', 'VLW'),
|
||||
('vlw/labylib-chattycape', 'REPO'),
|
||||
('vlw/labylib-animated-cape', 'VLW'),
|
||||
('vlw/labylib-animated-cape', 'REPO');
|
||||
|
||||
CREATE TABLE `work_timeline` (
|
||||
`ref_work_id` varchar(255) NOT NULL,
|
||||
`year` smallint(5) UNSIGNED NOT NULL,
|
||||
`month` tinyint(3) UNSIGNED NOT NULL,
|
||||
`day` tinyint(3) UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
INSERT INTO `work_timeline` (`ref_work_id`, `year`, `month`, `day`) VALUES
|
||||
('deltaco/asyncapp', 2020, 10, 18),
|
||||
('deltaco/distit', 2021, 1, 21),
|
||||
('deltaco/e-charge', 2021, 4, 6),
|
||||
('deltaco/office', 2020, 9, 4),
|
||||
('deltaco/pdf-generator', 2020, 9, 4),
|
||||
('deltaco/reseller-form', 2020, 8, 4),
|
||||
('icellate/genemate', 2022, 11, 7),
|
||||
('icellate/website', 2023, 4, 19),
|
||||
('itg/lan', 2014, 9, 2),
|
||||
('itg/upload', 2014, 6, 11),
|
||||
('vlw/camera-obscura', 2018, 4, 25),
|
||||
('vlw/collage', 2021, 3, 21),
|
||||
('vlw/dediprison', 2015, 10, 13),
|
||||
('vlw/disneyplus-pip', 2021, 1, 31),
|
||||
('vlw/edkb', 2021, 3, 18),
|
||||
('vlw/elevent', 2024, 11, 11),
|
||||
('vlw/eyeart', 2014, 3, 2),
|
||||
('vlw/ion-musik', 2015, 6, 11),
|
||||
('vlw/labylib', 2020, 11, 11),
|
||||
('vlw/labylib-animated-cape', 2020, 11, 15),
|
||||
('vlw/labylib-chattycape', 2020, 11, 15),
|
||||
('vlw/misskey-microblogger', 2024, 11, 9),
|
||||
('vlw/monkeydo', 2021, 10, 8),
|
||||
('vlw/php-age', 2023, 8, 22),
|
||||
('vlw/php-functionflags', 2023, 3, 16),
|
||||
('vlw/php-globalsnapshot', 2024, 4, 18),
|
||||
('vlw/php-mime-types', 2024, 10, 27),
|
||||
('vlw/php-mysql', 2023, 4, 8),
|
||||
('vlw/php-sqlite', 2023, 4, 18),
|
||||
('vlw/php-xenum', 2023, 6, 12),
|
||||
('vlw/pysheeter', 2020, 11, 20),
|
||||
('vlw/reflect', 2022, 11, 18),
|
||||
('vlw/stadia-avatar', 2021, 2, 3),
|
||||
('vlw/still-alive', 2021, 10, 12),
|
||||
('vlw/vegvisir', 2022, 11, 26),
|
||||
('vlw/vlw.se', 2023, 6, 13);
|
||||
|
||||
|
||||
ALTER TABLE `about_languages`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `coffee`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `search`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `keywords` (`query`(768));
|
||||
|
||||
ALTER TABLE `work`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `work_actions`
|
||||
ADD KEY `ref_work_id` (`ref_work_id`);
|
||||
|
||||
ALTER TABLE `work_tags`
|
||||
ADD KEY `anchor` (`ref_work_id`);
|
||||
|
||||
ALTER TABLE `work_timeline`
|
||||
ADD PRIMARY KEY (`ref_work_id`);
|
||||
|
||||
|
||||
ALTER TABLE `work_actions`
|
||||
ADD CONSTRAINT `work_actions_ibfk_1` FOREIGN KEY (`ref_work_id`) REFERENCES `work` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `work_tags`
|
||||
ADD CONSTRAINT `work_tags_ibfk_1` FOREIGN KEY (`ref_work_id`) REFERENCES `work` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `work_timeline`
|
||||
ADD CONSTRAINT `work_timeline_ibfk_1` FOREIGN KEY (`ref_work_id`) REFERENCES `work` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
97
src/Database/Seeds/vlw_reflect.sql
Normal file
97
src/Database/Seeds/vlw_reflect.sql
Normal file
|
@ -0,0 +1,97 @@
|
|||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
|
||||
CREATE TABLE `acl` (
|
||||
`ref_group` varchar(255) DEFAULT NULL,
|
||||
`ref_endpoint` varchar(255) NOT NULL,
|
||||
`method` enum('GET','POST','PUT','PATCH','DELETE') NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `endpoints` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
`active` tinyint(1) UNSIGNED NOT NULL DEFAULT 1
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
INSERT INTO `endpoints` (`id`, `active`) VALUES
|
||||
('about/languages', 1),
|
||||
('coffee', 1),
|
||||
('coffee/stats', 1),
|
||||
('messages', 1),
|
||||
('notes', 1),
|
||||
('playground/coffee', 1),
|
||||
('search', 1),
|
||||
('work', 1),
|
||||
('work/actions', 1),
|
||||
('work/tags', 1),
|
||||
('work/timeline', 1);
|
||||
|
||||
CREATE TABLE `groups` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
`active` tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
|
||||
`date_created` int(32) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `keys` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
`active` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`ref_user` varchar(255) DEFAULT NULL,
|
||||
`expires` int(32) DEFAULT NULL,
|
||||
`created` int(32) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `rel_users_groups` (
|
||||
`ref_user` varchar(255) NOT NULL,
|
||||
`ref_group` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
`active` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`created` int(32) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
ALTER TABLE `acl`
|
||||
ADD KEY `endpoint` (`ref_endpoint`),
|
||||
ADD KEY `ref_group` (`ref_group`);
|
||||
|
||||
ALTER TABLE `endpoints`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `groups`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
ALTER TABLE `keys`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `ref_user` (`ref_user`);
|
||||
|
||||
ALTER TABLE `rel_users_groups`
|
||||
ADD KEY `ref_user` (`ref_user`),
|
||||
ADD KEY `ref_group` (`ref_group`);
|
||||
|
||||
ALTER TABLE `users`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
|
||||
ALTER TABLE `acl`
|
||||
ADD CONSTRAINT `acl_ibfk_1` FOREIGN KEY (`ref_endpoint`) REFERENCES `endpoints` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `acl_ibfk_2` FOREIGN KEY (`ref_group`) REFERENCES `groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `keys`
|
||||
ADD CONSTRAINT `keys_ibfk_1` FOREIGN KEY (`ref_user`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `rel_users_groups`
|
||||
ADD CONSTRAINT `rel_users_groups_ibfk_1` FOREIGN KEY (`ref_user`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `rel_users_groups_ibfk_2` FOREIGN KEY (`ref_group`) REFERENCES `groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
Loading…
Add table
Reference in a new issue