Merge commit '1392bd3a96045302b60d845a90901a4b2234c475' as 'seatmap-webapi'

This commit is contained in:
zino
2021-01-20 12:59:59 +01:00
261 changed files with 39680 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,200 @@
-- Adminer 4.2.4 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'The identifier of the category.',
`name` varchar(255) NOT NULL COMMENT 'The name of the category.',
`icon` blob COMMENT 'A small image representing the category.',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='The post categories of the blog system.';
INSERT INTO `categories` (`name`, `icon`) VALUES
('announcement', NULL),
('article', NULL),
('comment', NULL);
DROP TABLE IF EXISTS `comments`;
CREATE TABLE `comments` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`message` varchar(255) NOT NULL,
`category_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `post_id` (`post_id`),
CONSTRAINT `comments_post_id_fkey` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),
CONSTRAINT `comments_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `comments` (`post_id`, `message`, `category_id`) VALUES
(1, 'great', 3),
(1, 'fantastic', 3),
(2, 'thank you', 3),
(2, 'awesome', 3);
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
`content` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `category_id` (`category_id`),
KEY `user_id` (`user_id`),
CONSTRAINT `posts_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`),
CONSTRAINT `posts_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `posts` (`user_id`, `category_id`, `content`) VALUES
(1, 1, 'blog started'),
(1, 2, 'It works!');
DROP TABLE IF EXISTS `post_tags`;
CREATE TABLE `post_tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `post_id` (`post_id`),
KEY `tag_id` (`tag_id`),
CONSTRAINT `post_tags_post_id_fkey` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),
CONSTRAINT `post_tags_tag_id_fkey` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `post_tags` (`post_id`, `tag_id`) VALUES
(1, 1),
(1, 2),
(2, 1),
(2, 2);
DROP TABLE IF EXISTS `tags`;
CREATE TABLE `tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`is_important` bit(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `tags` (`name`, `is_important`) VALUES
('funny', 0),
('important', 1);
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`location` point,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `users` (`username`, `password`, `location`) VALUES
('user1', 'pass1', NULL),
('user2', '$2y$10$cg7/nswxVZ0cmVIsMB/pVOh1OfcHScBJGq7Xu4KF9dFEQgRZ8HWe.', NULL);
DROP TABLE IF EXISTS `countries`;
CREATE TABLE `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`shape` geometry NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `countries` (`name`, `shape`) VALUES
('Left', ST_GeomFromText('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')),
('Right', ST_GeomFromText('POLYGON ((70 10, 80 40, 60 40, 50 20, 70 10))')),
('Point', ST_GeomFromText('POINT (30 10)')),
('Line', ST_GeomFromText('LINESTRING (30 10, 10 30, 40 40)')),
('Poly1', ST_GeomFromText('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')),
('Poly2', ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))')),
('Mpoint', ST_GeomFromText('MULTIPOINT (10 40, 40 30, 20 20, 30 10)')),
('Mline', ST_GeomFromText('MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))')),
('Mpoly1', ST_GeomFromText('MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))')),
('Mpoly2', ST_GeomFromText('MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))')),
('Gcoll', ST_GeomFromText('GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))'));
DROP TABLE IF EXISTS `events`;
CREATE TABLE `events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`datetime` datetime,
`visitors` bigint(20),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `events` (`name`, `datetime`, `visitors`) VALUES
('Launch', '2016-01-01 13:01:01', 0);
DROP VIEW IF EXISTS `tag_usage`;
CREATE VIEW `tag_usage` AS select `tags`.`id` as `id`, `name`, count(`name`) AS `count` from `tags`, `post_tags` where `tags`.`id` = `post_tags`.`tag_id` group by `tags`.`id`, `name` order by `count` desc, `name`;
DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`price` decimal(10,2) NOT NULL,
`properties` longtext NOT NULL,
`created_at` datetime NOT NULL,
`deleted_at` datetime,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `products` (`name`, `price`, `properties`, `created_at`) VALUES
('Calculator', '23.01', '{"depth":false,"model":"TRX-120","width":100,"height":null}', '1970-01-01 01:01:01');
DROP TABLE IF EXISTS `barcodes2`;
DROP TABLE IF EXISTS `barcodes`;
CREATE TABLE `barcodes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`hex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`bin` blob NOT NULL,
`ip_address` varchar(15),
PRIMARY KEY (`id`),
CONSTRAINT `barcodes_product_id_fkey` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `barcodes` (`product_id`, `hex`, `bin`, `ip_address`) VALUES
(1, '00ff01', UNHEX('00ff01'), '127.0.0.1');
DROP TABLE IF EXISTS `kunsthåndværk`;
CREATE TABLE `kunsthåndværk` (
`id` varchar(36) NOT NULL,
`Umlauts ä_ö_ü-COUNT` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`invisible` varchar(36),
`invisible_id` varchar(36),
PRIMARY KEY (`id`),
CONSTRAINT `kunsthåndværk_Umlauts ä_ö_ü-COUNT_fkey` UNIQUE (`Umlauts ä_ö_ü-COUNT`),
CONSTRAINT `kunsthåndværk_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
CONSTRAINT `kunsthåndværk_invisible_id_fkey` FOREIGN KEY (`invisible_id`) REFERENCES `invisibles` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `kunsthåndværk` (`id`, `Umlauts ä_ö_ü-COUNT`, `user_id`, `invisible`, `invisible_id`) VALUES
('e42c77c6-06a4-4502-816c-d112c7142e6d', 1, 1, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d'),
('e31ecfe6-591f-4660-9fbd-1a232083037f', 2, 2, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d');
DROP TABLE IF EXISTS `invisibles`;
CREATE TABLE `invisibles` (
`id` varchar(36) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `invisibles` (`id`) VALUES
('e42c77c6-06a4-4502-816c-d112c7142e6d');
DROP TABLE IF EXISTS `nopk`;
CREATE TABLE `nopk` (
`id` varchar(36) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `nopk` (`id`) VALUES
('e42c77c6-06a4-4502-816c-d112c7142e6d');
SET foreign_key_checks = 1;
-- 2016-11-05 13:11:47

View File

@@ -0,0 +1,548 @@
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Drop everything
--
DROP TABLE IF EXISTS categories CASCADE;
DROP TABLE IF EXISTS comments CASCADE;
DROP TABLE IF EXISTS post_tags CASCADE;
DROP TABLE IF EXISTS posts CASCADE;
DROP TABLE IF EXISTS tags CASCADE;
DROP TABLE IF EXISTS users CASCADE;
DROP TABLE IF EXISTS countries CASCADE;
DROP TABLE IF EXISTS events CASCADE;
DROP VIEW IF EXISTS tag_usage;
DROP TABLE IF EXISTS products CASCADE;
DROP TABLE IF EXISTS barcodes CASCADE;
DROP TABLE IF EXISTS barcodes2 CASCADE;
DROP TABLE IF EXISTS "kunsthåndværk" CASCADE;
DROP TABLE IF EXISTS invisibles CASCADE;
DROP TABLE IF EXISTS nopk CASCADE;
--
-- Name: categories; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE categories (
id serial NOT NULL,
name character varying(255) NOT NULL,
icon bytea
);
--
-- Name: comments; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE comments (
id bigserial NOT NULL,
post_id integer NOT NULL,
message character varying(255) NOT NULL,
category_id integer NOT NULL
);
--
-- Name: post_tags; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE post_tags (
id serial NOT NULL,
post_id integer NOT NULL,
tag_id integer NOT NULL
);
--
-- Name: posts; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE posts (
id serial NOT NULL,
user_id integer NOT NULL,
category_id integer NOT NULL,
content character varying(255) NOT NULL
);
--
-- Name: tags; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE tags (
id serial NOT NULL,
name character varying(255) NOT NULL,
is_important boolean NOT NULL
);
--
-- Name: users; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE users (
id serial NOT NULL,
username character varying(255) NOT NULL,
password character varying(255) NOT NULL,
location geometry
);
--
-- Name: countries; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE countries (
id serial NOT NULL,
name character varying(255) NOT NULL,
shape geometry NOT NULL
);
--
-- Name: events; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE events (
id serial NOT NULL,
name character varying(255) NOT NULL,
datetime timestamp,
visitors bigint
);
--
-- Name: tag_usage; Type: VIEW; Schema: public; Owner: postgres; Tablespace:
--
CREATE VIEW "tag_usage" AS select "tags"."id" as "id", "name", count("name") AS "count" from "tags", "post_tags" where "tags"."id" = "post_tags"."tag_id" group by "tags"."id", "name" order by "count" desc, "name";
--
-- Name: products; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE products (
id serial NOT NULL,
name character varying(255) NOT NULL,
price decimal(10,2) NOT NULL,
properties jsonb NOT NULL,
created_at timestamp NOT NULL,
deleted_at timestamp NULL
);
--
-- Name: barcodes; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE barcodes (
id serial NOT NULL,
product_id integer NOT NULL,
hex character varying(255) NOT NULL,
bin bytea NOT NULL,
ip_address character varying(15)
);
--
-- Name: kunsthåndværk; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "kunsthåndværk" (
id character varying(36) NOT NULL,
"Umlauts ä_ö_ü-COUNT" integer NOT NULL,
user_id integer NOT NULL,
invisible character varying(36),
invisible_id character varying(36)
);
--
-- Name: invisibles; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "invisibles" (
id character varying(36) NOT NULL
);
--
-- Name: nopk; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "nopk" (
id character varying(36) NOT NULL
);
--
-- Data for Name: categories; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "categories" ("name", "icon") VALUES
('announcement', NULL),
('article', NULL),
('comment', NULL);
--
-- Data for Name: comments; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "comments" ("post_id", "message", "category_id") VALUES
(1, 'great', 3),
(1, 'fantastic', 3),
(2, 'thank you', 3),
(2, 'awesome', 3);
--
-- Data for Name: post_tags; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "post_tags" ("post_id", "tag_id") VALUES
(1, 1),
(1, 2),
(2, 1),
(2, 2);
--
-- Data for Name: posts; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "posts" ("user_id", "category_id", "content") VALUES
(1, 1, 'blog started'),
(1, 2, 'It works!');
--
-- Data for Name: tags; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "tags" ("name", "is_important") VALUES
('funny', false),
('important', true);
--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "users" ("username", "password", "location") VALUES
('user1', 'pass1', NULL),
('user2', '$2y$10$cg7/nswxVZ0cmVIsMB/pVOh1OfcHScBJGq7Xu4KF9dFEQgRZ8HWe.', NULL);
--
-- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "countries" ("name", "shape") VALUES
('Left', ST_GeomFromText('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')),
('Right', ST_GeomFromText('POLYGON ((70 10, 80 40, 60 40, 50 20, 70 10))')),
('Point', ST_GeomFromText('POINT (30 10)')),
('Line', ST_GeomFromText('LINESTRING (30 10, 10 30, 40 40)')),
('Poly1', ST_GeomFromText('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')),
('Poly2', ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))')),
('Mpoint', ST_GeomFromText('MULTIPOINT (10 40, 40 30, 20 20, 30 10)')),
('Mline', ST_GeomFromText('MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))')),
('Mpoly1', ST_GeomFromText('MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))')),
('Mpoly2', ST_GeomFromText('MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))')),
('Gcoll', ST_GeomFromText('GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))'));
--
-- Data for Name: events; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "events" ("name", "datetime", "visitors") VALUES
('Launch', '2016-01-01 13:01:01', 0);
--
-- Data for Name: products; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "products" ("name", "price", "properties", "created_at") VALUES
('Calculator', '23.01', '{"depth":false,"model":"TRX-120","width":100,"height":null}', '1970-01-01 01:01:01');
--
-- Data for Name: barcodes; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "barcodes" ("product_id", "hex", "bin", "ip_address") VALUES
(1, '00ff01', E'\\x00ff01', '127.0.0.1');
--
-- Data for Name: kunsthåndværk; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "kunsthåndværk" ("id", "Umlauts ä_ö_ü-COUNT", "user_id", "invisible", "invisible_id") VALUES
('e42c77c6-06a4-4502-816c-d112c7142e6d', 1, 1, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d'),
('e31ecfe6-591f-4660-9fbd-1a232083037f', 2, 2, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d');
--
-- Data for Name: invisibles; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "invisibles" ("id") VALUES
('e42c77c6-06a4-4502-816c-d112c7142e6d');
--
-- Data for Name: nopk; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO "nopk" ("id") VALUES
('e42c77c6-06a4-4502-816c-d112c7142e6d');
--
-- Name: categories_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY categories
ADD CONSTRAINT categories_pkey PRIMARY KEY (id);
--
-- Name: comments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY comments
ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
--
-- Name: post_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY post_tags
ADD CONSTRAINT post_tags_pkey PRIMARY KEY (id);
--
-- Name: post_tags_post_id_tag_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY post_tags
ADD CONSTRAINT post_tags_post_id_tag_id_key UNIQUE (post_id, tag_id);
--
-- Name: posts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY posts
ADD CONSTRAINT posts_pkey PRIMARY KEY (id);
--
-- Name: tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY tags
ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
--
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: countries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY countries
ADD CONSTRAINT countries_pkey PRIMARY KEY (id);
--
-- Name: events_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY events
ADD CONSTRAINT events_pkey PRIMARY KEY (id);
--
-- Name: products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY products
ADD CONSTRAINT products_pkey PRIMARY KEY (id);
--
-- Name: barcodes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY barcodes
ADD CONSTRAINT barcodes_pkey PRIMARY KEY (id);
--
-- Name: kunsthåndværk_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY "kunsthåndværk"
ADD CONSTRAINT "kunsthåndværk_pkey" PRIMARY KEY (id);
--
-- Name: invisibles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY "invisibles"
ADD CONSTRAINT "invisibles_pkey" PRIMARY KEY (id);
--
-- Name: comments_post_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX comments_post_id_idx ON comments USING btree (post_id);
--
-- Name: comments_category_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX comments_category_id_idx ON comments USING btree (category_id);
--
-- Name: post_tags_post_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX post_tags_post_id_idx ON post_tags USING btree (post_id);
--
-- Name: post_tags_tag_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX post_tags_tag_id_idx ON post_tags USING btree (tag_id);
--
-- Name: posts_category_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX posts_category_id_idx ON posts USING btree (category_id);
--
-- Name: posts_user_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX posts_user_id_idx ON posts USING btree (user_id);
--
-- Name: barcodes_product_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX barcodes_product_id_idx ON barcodes USING btree (product_id);
--
-- Name: kunsthåndværk_Umlauts ä_ö_ü-COUNT_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX "kunsthåndværk_Umlauts ä_ö_ü-COUNT_idx" ON "kunsthåndværk" USING btree ("Umlauts ä_ö_ü-COUNT");
--
-- Name: kunsthåndværk_user_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX "kunsthåndværk_user_id_idx" ON "kunsthåndværk" USING btree (user_id);
--
-- Name: kunsthåndværk_invisible_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX "kunsthåndværk_invisible_id_idx" ON "kunsthåndværk" USING btree (invisible_id);
--
-- Name: comments_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY comments
ADD CONSTRAINT comments_post_id_fkey FOREIGN KEY (post_id) REFERENCES posts(id);
--
-- Name: comments_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY comments
ADD CONSTRAINT comments_category_id_fkey FOREIGN KEY (category_id) REFERENCES categories(id);
--
-- Name: post_tags_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY post_tags
ADD CONSTRAINT post_tags_post_id_fkey FOREIGN KEY (post_id) REFERENCES posts(id);
--
-- Name: post_tags_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY post_tags
ADD CONSTRAINT post_tags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tags(id);
--
-- Name: posts_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY posts
ADD CONSTRAINT posts_category_id_fkey FOREIGN KEY (category_id) REFERENCES categories(id);
--
-- Name: posts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY posts
ADD CONSTRAINT posts_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
--
-- Name: barcodes_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY barcodes
ADD CONSTRAINT barcodes_product_id_fkey FOREIGN KEY (product_id) REFERENCES products(id);
--
-- Name: kunsthåndværk_Umlauts ä_ö_ü-COUNT_uc; Type: UNIQUE CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "kunsthåndværk"
ADD CONSTRAINT "kunsthåndværk_Umlauts ä_ö_ü-COUNT_uc" UNIQUE ("Umlauts ä_ö_ü-COUNT");
--
-- Name: kunsthåndværk_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "kunsthåndværk"
ADD CONSTRAINT "kunsthåndværk_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id);
--
-- Name: kunsthåndværk_invisible_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "kunsthåndværk"
ADD CONSTRAINT "kunsthåndværk_invisible_id_fkey" FOREIGN KEY (invisible_id) REFERENCES invisibles(id);
--
-- PostgreSQL database dump complete
--

View File

@@ -0,0 +1,175 @@
-- Adminer 4.2.4 SQLite 3 dump
PRAGMA foreign_keys = off;
DROP TABLE IF EXISTS "categories";
CREATE TABLE "categories" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL,
"icon" blob NULL
);
INSERT INTO "categories" ("id", "name", "icon") VALUES (1, 'announcement', NULL);
INSERT INTO "categories" ("id", "name", "icon") VALUES (2, 'article', NULL);
INSERT INTO "categories" ("id", "name", "icon") VALUES (3, 'comment', NULL);
DROP TABLE IF EXISTS "comments";
CREATE TABLE "comments" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"post_id" integer NOT NULL,
"message" VARCHAR(255) NOT NULL,
"category_id" integer NOT NULL,
FOREIGN KEY ("post_id") REFERENCES "posts" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY ("category_id") REFERENCES "categories" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);
CREATE INDEX "comments_post_id" ON "comments" ("post_id");
CREATE INDEX "comments_category_id" ON "comments" ("category_id");
INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (1, 1, 'great', 3);
INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (2, 1, 'fantastic', 3);
INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (3, 2, 'thank you', 3);
INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (4, 2, 'awesome', 3);
DROP TABLE IF EXISTS "posts";
CREATE TABLE "posts" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"user_id" integer NOT NULL,
"category_id" integer NOT NULL,
"content" varchar(255) NOT NULL,
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY ("category_id") REFERENCES "categories" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);
CREATE INDEX "posts_user_id" ON "posts" ("user_id");
CREATE INDEX "posts_category_id" ON "posts" ("category_id");
INSERT INTO "posts" ("id", "user_id", "category_id", "content") VALUES (1, 1, 1, 'blog started');
INSERT INTO "posts" ("id", "user_id", "category_id", "content") VALUES (2, 1, 2, 'It works!');
DROP TABLE IF EXISTS "post_tags";
CREATE TABLE "post_tags" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"post_id" integer NOT NULL,
"tag_id" integer NOT NULL,
FOREIGN KEY ("tag_id") REFERENCES "tags" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY ("post_id") REFERENCES "posts" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);
CREATE UNIQUE INDEX "post_tags_post_id_tag_id" ON "post_tags" ("post_id", "tag_id");
INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (1, 1, 1);
INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (2, 1, 2);
INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (3, 2, 1);
INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (4, 2, 2);
DROP TABLE IF EXISTS "tags";
CREATE TABLE "tags" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL,
"is_important" boolean NOT NULL
);
INSERT INTO "tags" ("id", "name", "is_important") VALUES (1, 'funny', 0);
INSERT INTO "tags" ("id", "name", "is_important") VALUES (2, 'important', 1);
DROP TABLE IF EXISTS "users";
CREATE TABLE "users" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" varchar(255) NOT NULL,
"password" varchar(255) NOT NULL,
"location" text NULL
);
INSERT INTO "users" ("id", "username", "password", "location") VALUES (1, 'user1', 'pass1', NULL);
INSERT INTO "users" ("id", "username", "password", "location") VALUES (2, 'user2', '$2y$10$cg7/nswxVZ0cmVIsMB/pVOh1OfcHScBJGq7Xu4KF9dFEQgRZ8HWe.', NULL);
DROP TABLE IF EXISTS "countries";
CREATE TABLE "countries" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL,
"shape" text NOT NULL
);
INSERT INTO "countries" ("id", "name", "shape") VALUES (1, 'Left', 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (2, 'Right', 'POLYGON ((70 10, 80 40, 60 40, 50 20, 70 10))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (3, 'Point', 'POINT (30 10)');
INSERT INTO "countries" ("id", "name", "shape") VALUES (4, 'Line', 'LINESTRING (30 10, 10 30, 40 40)');
INSERT INTO "countries" ("id", "name", "shape") VALUES (5, 'Poly1', 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (6, 'Poly2', 'POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (7, 'Mpoint', 'MULTIPOINT (10 40, 40 30, 20 20, 30 10)');
INSERT INTO "countries" ("id", "name", "shape") VALUES (8, 'Mline', 'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (9, 'Mpoly1', 'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (10, 'Mpoly2', 'MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))');
INSERT INTO "countries" ("id", "name", "shape") VALUES (11, 'Gcoll', 'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))');
DROP TABLE IF EXISTS "events";
CREATE TABLE "events" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL,
"datetime" datetime,
"visitors" bigint
);
INSERT INTO "events" ("id", "name", "datetime", "visitors") VALUES (1, 'Launch', '2016-01-01 13:01:01', 0);
DROP VIEW IF EXISTS "tag_usage";
CREATE VIEW "tag_usage" AS select "tags"."id" as "id", "name", count("name") AS "count" from "tags", "post_tags" where "tags"."id" = "post_tags"."tag_id" group by "tags"."id", "name" order by "count" desc, "name";
DROP TABLE IF EXISTS "products";
CREATE TABLE "products" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" varchar(255) NOT NULL,
"price" decimal(10,2) NOT NULL,
"properties" clob NOT NULL,
"created_at" datetime NOT NULL,
"deleted_at" datetime NULL
);
INSERT INTO "products" ("id", "name", "price", "properties", "created_at") VALUES (1, 'Calculator', '23.01', '{"depth":false,"model":"TRX-120","width":100,"height":null}', '1970-01-01 01:01:01');
DROP TABLE IF EXISTS "barcodes2";
DROP TABLE IF EXISTS "barcodes";
CREATE TABLE "barcodes" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"product_id" integer NOT NULL,
"hex" varchar(255) NOT NULL,
"bin" blob NOT NULL,
"ip_address" varchar(15),
FOREIGN KEY ("product_id") REFERENCES "products" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);
INSERT INTO "barcodes" ("id", "product_id", "hex", "bin", "ip_address") VALUES (1, 1, '00ff01', 'AP8B', '127.0.0.1');
DROP TABLE IF EXISTS "kunsthåndværk";
CREATE TABLE "kunsthåndværk" (
"id" varchar(36) NOT NULL PRIMARY KEY,
"Umlauts ä_ö_ü-COUNT" integer NOT NULL UNIQUE,
"user_id" integer NOT NULL,
"invisible" varchar(36),
"invisible_id" varchar(36),
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY ("invisible_id") REFERENCES "invisibles" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
);
INSERT INTO "kunsthåndværk" ("id", "Umlauts ä_ö_ü-COUNT", "user_id", "invisible", "invisible_id") VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d', 1, 1, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d');
INSERT INTO "kunsthåndværk" ("id", "Umlauts ä_ö_ü-COUNT", "user_id", "invisible", "invisible_id") VALUES ('e31ecfe6-591f-4660-9fbd-1a232083037f', 2, 2, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d');
DROP TABLE IF EXISTS "invisibles";
CREATE TABLE "invisibles" (
"id" varchar(36) NOT NULL PRIMARY KEY
);
INSERT INTO "invisibles" ("id") VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d');
DROP TABLE IF EXISTS "nopk";
CREATE TABLE "nopk" (
"id" varchar(36) NOT NULL
);
INSERT INTO "nopk" ("id") VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d');
PRAGMA foreign_keys = on;
--

View File

@@ -0,0 +1,442 @@
IF (OBJECT_ID('kunsthåndværk_user_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [kunsthåndværk] DROP CONSTRAINT [kunsthåndværk_user_id_fkey]
END
GO
IF (OBJECT_ID('barcodes_product_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [barcodes] DROP CONSTRAINT [barcodes_product_id_fkey]
END
GO
IF (OBJECT_ID('posts_user_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [posts] DROP CONSTRAINT [posts_user_id_fkey]
END
GO
IF (OBJECT_ID('posts_category_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [posts] DROP CONSTRAINT [posts_category_id_fkey]
END
GO
IF (OBJECT_ID('post_tags_tag_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [post_tags] DROP CONSTRAINT [post_tags_tag_id_fkey]
END
GO
IF (OBJECT_ID('post_tags_post_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [post_tags] DROP CONSTRAINT [post_tags_post_id_fkey]
END
GO
IF (OBJECT_ID('comments_post_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [comments] DROP CONSTRAINT [comments_post_id_fkey]
END
GO
IF (OBJECT_ID('comments_category_id_fkey', 'F') IS NOT NULL)
BEGIN
ALTER TABLE [comments] DROP CONSTRAINT [comments_category_id_fkey]
END
GO
IF (OBJECT_ID('barcodes2', 'U') IS NOT NULL)
BEGIN
DROP TABLE [barcodes2]
END
GO
IF (OBJECT_ID('barcodes', 'U') IS NOT NULL)
BEGIN
DROP TABLE [barcodes]
END
GO
IF (OBJECT_ID('products', 'U') IS NOT NULL)
BEGIN
DROP TABLE [products]
END
GO
IF (OBJECT_ID('events', 'U') IS NOT NULL)
BEGIN
DROP TABLE [events]
END
GO
IF (OBJECT_ID('countries', 'U') IS NOT NULL)
BEGIN
DROP TABLE [countries]
END
GO
IF (OBJECT_ID('users', 'U') IS NOT NULL)
BEGIN
DROP TABLE [users]
END
GO
IF (OBJECT_ID('tags', 'U') IS NOT NULL)
BEGIN
DROP TABLE [tags]
END
GO
IF (OBJECT_ID('posts', 'U') IS NOT NULL)
BEGIN
DROP TABLE [posts]
END
GO
IF (OBJECT_ID('post_tags', 'U') IS NOT NULL)
BEGIN
DROP TABLE [post_tags]
END
GO
IF (OBJECT_ID('comments', 'U') IS NOT NULL)
BEGIN
DROP TABLE [comments]
END
GO
IF (OBJECT_ID('categories', 'U') IS NOT NULL)
BEGIN
DROP TABLE [categories]
END
GO
IF (OBJECT_ID('tag_usage', 'V') IS NOT NULL)
BEGIN
DROP VIEW [tag_usage]
END
GO
IF (OBJECT_ID('kunsthåndværk', 'U') IS NOT NULL)
BEGIN
DROP TABLE [kunsthåndværk]
END
GO
IF (OBJECT_ID('invisibles', 'U') IS NOT NULL)
BEGIN
DROP TABLE [invisibles]
END
GO
IF (OBJECT_ID('nopk', 'U') IS NOT NULL)
BEGIN
DROP TABLE [nopk]
END
GO
DROP SEQUENCE IF EXISTS [categories_id_seq]
GO
CREATE SEQUENCE [categories_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [categories](
[id] [int] NOT NULL CONSTRAINT [categories_id_def] DEFAULT NEXT VALUE FOR [categories_id_seq],
[name] [nvarchar](255) NOT NULL,
[icon] [image],
CONSTRAINT [categories_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [comments_id_seq]
GO
CREATE SEQUENCE [comments_id_seq] AS bigint START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [comments](
[id] [bigint] NOT NULL CONSTRAINT [comments_id_def] DEFAULT NEXT VALUE FOR [comments_id_seq],
[post_id] [int] NOT NULL,
[message] [nvarchar](255) NOT NULL,
[category_id] [int] NOT NULL,
CONSTRAINT [comments_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [post_tags_id_seq]
GO
CREATE SEQUENCE [post_tags_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [post_tags](
[id] [int] NOT NULL CONSTRAINT [post_tags_id_def] DEFAULT NEXT VALUE FOR [post_tags_id_seq],
[post_id] [int] NOT NULL,
[tag_id] [int] NOT NULL,
CONSTRAINT [post_tags_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [posts_id_seq]
GO
CREATE SEQUENCE [posts_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [posts](
[id] [int] NOT NULL CONSTRAINT [posts_id_def] DEFAULT NEXT VALUE FOR [posts_id_seq],
[user_id] [int] NOT NULL,
[category_id] [int] NOT NULL,
[content] [nvarchar](255) NOT NULL,
CONSTRAINT [posts_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [tags_id_seq]
GO
CREATE SEQUENCE [tags_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [tags](
[id] [int] NOT NULL CONSTRAINT [tags_id_def] DEFAULT NEXT VALUE FOR [tags_id_seq],
[name] [nvarchar](255) NOT NULL,
[is_important] [bit] NOT NULL,
CONSTRAINT [tags_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [users_id_seq]
GO
CREATE SEQUENCE [users_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [users](
[id] [int] NOT NULL CONSTRAINT [users_id_def] DEFAULT NEXT VALUE FOR [users_id_seq],
[username] [nvarchar](255) NOT NULL,
[password] [nvarchar](255) NOT NULL,
[location] [geometry],
CONSTRAINT [users_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [countries_id_seq]
GO
CREATE SEQUENCE [countries_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [countries](
[id] [int] NOT NULL CONSTRAINT [countries_id_def] DEFAULT NEXT VALUE FOR [countries_id_seq],
[name] [nvarchar](255) NOT NULL,
[shape] [geometry] NOT NULL,
CONSTRAINT [countries_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [events_id_seq]
GO
CREATE SEQUENCE [events_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [events](
[id] [int] NOT NULL CONSTRAINT [events_id_def] DEFAULT NEXT VALUE FOR [events_id_seq],
[name] [nvarchar](255) NOT NULL,
[datetime] [datetime2](0),
[visitors] [bigint],
CONSTRAINT [events_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
CREATE VIEW [tag_usage]
AS
SELECT top 100 PERCENT tags.id as id, name, COUNT_BIG(name) AS [count] FROM tags, post_tags WHERE tags.id = post_tags.tag_id GROUP BY tags.id, name ORDER BY [count] DESC, name
GO
DROP SEQUENCE IF EXISTS [products_id_seq]
GO
CREATE SEQUENCE [products_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [products](
[id] [int] NOT NULL CONSTRAINT [products_id_def] DEFAULT NEXT VALUE FOR [products_id_seq],
[name] [nvarchar](255) NOT NULL,
[price] [decimal](10,2) NOT NULL,
[properties] [xml] NOT NULL,
[created_at] [datetime2](0) NOT NULL,
[deleted_at] [datetime2](0),
CONSTRAINT [products_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
DROP SEQUENCE IF EXISTS [barcodes_id_seq]
GO
CREATE SEQUENCE [barcodes_id_seq] AS int START WITH 1 INCREMENT BY 1 NO CACHE
GO
CREATE TABLE [barcodes](
[id] [int] NOT NULL CONSTRAINT [barcodes_id_def] DEFAULT NEXT VALUE FOR [barcodes_id_seq],
[product_id] [int] NOT NULL,
[hex] [nvarchar](255) NOT NULL,
[bin] [varbinary](max) NOT NULL,
[ip_address] [nvarchar](15),
CONSTRAINT [barcodes_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
CREATE TABLE [kunsthåndværk](
[id] [nvarchar](36) NOT NULL,
[Umlauts ä_ö_ü-COUNT] [int] NOT NULL,
[user_id] [int] NOT NULL,
[invisible] [nvarchar](36),
[invisible_id] [nvarchar](36),
CONSTRAINT [kunsthåndværk_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
CREATE TABLE [invisibles](
[id] [nvarchar](36) NOT NULL,
CONSTRAINT [invisibles_pkey] PRIMARY KEY CLUSTERED([id] ASC)
)
GO
CREATE TABLE [nopk](
[id] [nvarchar](36) NOT NULL
)
GO
INSERT [categories] ([name], [icon]) VALUES (N'announcement', NULL)
GO
INSERT [categories] ([name], [icon]) VALUES (N'article', NULL)
GO
INSERT [categories] ([name], [icon]) VALUES (N'comment', NULL)
GO
INSERT [comments] ([post_id], [message], [category_id]) VALUES (1, N'great', 3)
GO
INSERT [comments] ([post_id], [message], [category_id]) VALUES (1, N'fantastic', 3)
GO
INSERT [comments] ([post_id], [message], [category_id]) VALUES (2, N'thank you', 3)
GO
INSERT [comments] ([post_id], [message], [category_id]) VALUES (2, N'awesome', 3)
GO
INSERT [post_tags] ([post_id], [tag_id]) VALUES (1, 1)
GO
INSERT [post_tags] ([post_id], [tag_id]) VALUES (1, 2)
GO
INSERT [post_tags] ([post_id], [tag_id]) VALUES (2, 1)
GO
INSERT [post_tags] ([post_id], [tag_id]) VALUES (2, 2)
GO
INSERT [posts] ([user_id], [category_id], [content]) VALUES (1, 1, N'blog started')
GO
INSERT [posts] ([user_id], [category_id], [content]) VALUES (1, 2, N'It works!')
GO
INSERT [tags] ([name], [is_important]) VALUES (N'funny', 0)
GO
INSERT [tags] ([name], [is_important]) VALUES (N'important', 1)
GO
INSERT [users] ([username], [password], [location]) VALUES (N'user1', N'pass1', NULL)
GO
INSERT [users] ([username], [password], [location]) VALUES (N'user2', N'$2y$10$cg7/nswxVZ0cmVIsMB/pVOh1OfcHScBJGq7Xu4KF9dFEQgRZ8HWe.', NULL)
GO
INSERT [countries] ([name], [shape]) VALUES (N'Left', N'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Right', N'POLYGON ((70 10, 80 40, 60 40, 50 20, 70 10))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Point', N'POINT (30 10)')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Line', N'LINESTRING (30 10, 10 30, 40 40)')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Poly1', N'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Poly2', N'POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Mpoint', N'MULTIPOINT (10 40, 40 30, 20 20, 30 10)')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Mline', N'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Mpoly1', N'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Mpoly2', N'MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))')
GO
INSERT [countries] ([name], [shape]) VALUES (N'Gcoll', N'GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))')
GO
INSERT [events] ([name], [datetime], [visitors]) VALUES (N'Launch', N'2016-01-01 13:01:01', 0)
GO
INSERT [products] ([name], [price], [properties], [created_at]) VALUES (N'Calculator', N'23.01', N'<root type="object"><depth type="boolean">false</depth><model type="string">TRX-120</model><width type="number">100</width><height type="null" /></root>', '1970-01-01 01:01:01')
GO
INSERT [barcodes] ([product_id], [hex], [bin], [ip_address]) VALUES (1, N'00ff01', 0x00ff01, N'127.0.0.1')
GO
INSERT [kunsthåndværk] ([id], [Umlauts ä_ö_ü-COUNT], [user_id], [invisible], [invisible_id]) VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d', 1, 1, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d')
GO
INSERT [kunsthåndværk] ([id], [Umlauts ä_ö_ü-COUNT], [user_id], [invisible], [invisible_id]) VALUES ('e31ecfe6-591f-4660-9fbd-1a232083037f', 2, 2, NULL, 'e42c77c6-06a4-4502-816c-d112c7142e6d')
GO
INSERT [invisibles] ([id]) VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d')
GO
INSERT [nopk] ([id]) VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d')
GO
ALTER TABLE [comments] WITH CHECK ADD CONSTRAINT [comments_post_id_fkey] FOREIGN KEY([post_id])
REFERENCES [posts] ([id])
GO
ALTER TABLE [comments] CHECK CONSTRAINT [comments_post_id_fkey]
GO
ALTER TABLE [comments] WITH CHECK ADD CONSTRAINT [comments_category_id_fkey] FOREIGN KEY([category_id])
REFERENCES [categories] ([id])
GO
ALTER TABLE [comments] CHECK CONSTRAINT [comments_category_id_fkey]
GO
ALTER TABLE [post_tags] WITH CHECK ADD CONSTRAINT [post_tags_post_id_fkey] FOREIGN KEY([post_id])
REFERENCES [posts] ([id])
GO
ALTER TABLE [post_tags] CHECK CONSTRAINT [post_tags_post_id_fkey]
GO
ALTER TABLE [post_tags] WITH CHECK ADD CONSTRAINT [post_tags_tag_id_fkey] FOREIGN KEY([tag_id])
REFERENCES [tags] ([id])
GO
ALTER TABLE [post_tags] CHECK CONSTRAINT [post_tags_tag_id_fkey]
GO
ALTER TABLE [posts] WITH CHECK ADD CONSTRAINT [posts_category_id_fkey] FOREIGN KEY([category_id])
REFERENCES [categories] ([id])
GO
ALTER TABLE [posts] CHECK CONSTRAINT [posts_category_id_fkey]
GO
ALTER TABLE [posts] WITH CHECK ADD CONSTRAINT [posts_user_id_fkey] FOREIGN KEY([user_id])
REFERENCES [users] ([id])
GO
ALTER TABLE [posts] CHECK CONSTRAINT [posts_user_id_fkey]
GO
ALTER TABLE [barcodes] WITH CHECK ADD CONSTRAINT [barcodes_product_id_fkey] FOREIGN KEY([product_id])
REFERENCES [products] ([id])
GO
ALTER TABLE [barcodes] CHECK CONSTRAINT [barcodes_product_id_fkey]
GO
ALTER TABLE [kunsthåndværk] WITH CHECK ADD CONSTRAINT [UC_kunsthåndværk_Umlauts ä_ö_ü-COUNT] UNIQUE([Umlauts ä_ö_ü-COUNT])
GO
ALTER TABLE [kunsthåndværk] WITH CHECK ADD CONSTRAINT [kunsthåndværk_user_id_fkey] FOREIGN KEY([user_id])
REFERENCES [users] ([id])
GO
ALTER TABLE [kunsthåndværk] CHECK CONSTRAINT [kunsthåndværk_user_id_fkey]
GO
ALTER TABLE [kunsthåndværk] WITH CHECK ADD CONSTRAINT [kunsthåndværk_invisible_id_fkey] FOREIGN KEY([invisible_id])
REFERENCES [invisibles] ([id])
GO
ALTER TABLE [kunsthåndværk] CHECK CONSTRAINT [kunsthåndværk_invisible_id_fkey]
GO

View File

@@ -0,0 +1,4 @@
CREATE DATABASE `php-crud-api` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'php-crud-api'@'localhost' IDENTIFIED BY 'php-crud-api';
GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

View File

@@ -0,0 +1,5 @@
CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
CREATE DATABASE "php-crud-api";
GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
\c "php-crud-api";
CREATE EXTENSION IF NOT EXISTS postgis;

View File

@@ -0,0 +1,9 @@
CREATE DATABASE [php-crud-api]
GO
CREATE LOGIN [php-crud-api] WITH PASSWORD=N'php-crud-api', DEFAULT_DATABASE=[php-crud-api], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
USE [php-crud-api]
GO
CREATE USER [php-crud-api] FOR LOGIN [php-crud-api] WITH DEFAULT_SCHEMA=[dbo]
exec sp_addrolemember 'db_owner', 'php-crud-api';
GO