Fix: drop queries fail because of foreign key constraints
This commit is contained in:
parent
c65c3605ef
commit
93b3848f81
@ -5,6 +5,17 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS `ulogger` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
CREATE DATABASE IF NOT EXISTS `ulogger` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
USE `ulogger`;
|
USE `ulogger`;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Drop tables if exist
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `positions`;
|
||||||
|
DROP TABLE IF EXISTS `tracks`;
|
||||||
|
DROP TABLE IF EXISTS `users`;
|
||||||
|
DROP TABLE IF EXISTS `config`;
|
||||||
|
DROP TABLE IF EXISTS `ol_layers`;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
@ -12,7 +23,6 @@ USE `ulogger`;
|
|||||||
-- Table structure for table `users`
|
-- Table structure for table `users`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `users`;
|
|
||||||
CREATE TABLE `users` (
|
CREATE TABLE `users` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
`login` varchar(15) CHARACTER SET latin1 NOT NULL UNIQUE,
|
`login` varchar(15) CHARACTER SET latin1 NOT NULL UNIQUE,
|
||||||
@ -26,7 +36,6 @@ CREATE TABLE `users` (
|
|||||||
-- Table structure for table `tracks`
|
-- Table structure for table `tracks`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `tracks`;
|
|
||||||
CREATE TABLE `tracks` (
|
CREATE TABLE `tracks` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
`user_id` int(11) NOT NULL,
|
`user_id` int(11) NOT NULL,
|
||||||
@ -42,7 +51,6 @@ CREATE TABLE `tracks` (
|
|||||||
-- Table structure for table `positions`
|
-- Table structure for table `positions`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `positions`;
|
|
||||||
CREATE TABLE `positions` (
|
CREATE TABLE `positions` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
@ -69,7 +77,6 @@ CREATE TABLE `positions` (
|
|||||||
-- Table structure for table `config`
|
-- Table structure for table `config`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `config`;
|
|
||||||
CREATE TABLE `config` (
|
CREATE TABLE `config` (
|
||||||
`name` varchar(20) PRIMARY KEY,
|
`name` varchar(20) PRIMARY KEY,
|
||||||
`value` tinyblob NOT NULL
|
`value` tinyblob NOT NULL
|
||||||
@ -106,7 +113,6 @@ INSERT INTO `config` (`name`, `value`) VALUES
|
|||||||
-- Table structure for table `ol_layers`
|
-- Table structure for table `ol_layers`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `ol_layers`;
|
|
||||||
CREATE TABLE `ol_layers` (
|
CREATE TABLE `ol_layers` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
`name` varchar(50) NOT NULL,
|
`name` varchar(50) NOT NULL,
|
||||||
|
@ -5,6 +5,17 @@
|
|||||||
CREATE DATABASE ulogger WITH ENCODING='UTF8' LC_COLLATE = 'en_US.utf-8' LC_CTYPE = 'en_US.utf-8';
|
CREATE DATABASE ulogger WITH ENCODING='UTF8' LC_COLLATE = 'en_US.utf-8' LC_CTYPE = 'en_US.utf-8';
|
||||||
\connect ulogger;
|
\connect ulogger;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Drop tables if exist
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS positions;
|
||||||
|
DROP TABLE IF EXISTS tracks;
|
||||||
|
DROP TABLE IF EXISTS users;
|
||||||
|
DROP TABLE IF EXISTS config;
|
||||||
|
DROP TABLE IF EXISTS ol_layers;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
@ -12,7 +23,6 @@ CREATE DATABASE ulogger WITH ENCODING='UTF8' LC_COLLATE = 'en_US.utf-8' LC_CTYPE
|
|||||||
-- Table structure for table `users`
|
-- Table structure for table `users`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS users;
|
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
id serial PRIMARY KEY,
|
id serial PRIMARY KEY,
|
||||||
login varchar(15) NOT NULL UNIQUE,
|
login varchar(15) NOT NULL UNIQUE,
|
||||||
@ -26,7 +36,6 @@ CREATE TABLE users (
|
|||||||
-- Table structure for table `tracks`
|
-- Table structure for table `tracks`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS tracks;
|
|
||||||
CREATE TABLE tracks (
|
CREATE TABLE tracks (
|
||||||
id serial PRIMARY KEY,
|
id serial PRIMARY KEY,
|
||||||
user_id int NOT NULL,
|
user_id int NOT NULL,
|
||||||
@ -43,7 +52,6 @@ CREATE INDEX idx_user_id ON tracks(user_id);
|
|||||||
-- Table structure for table `positions`
|
-- Table structure for table `positions`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS positions;
|
|
||||||
CREATE TABLE positions (
|
CREATE TABLE positions (
|
||||||
id serial PRIMARY KEY,
|
id serial PRIMARY KEY,
|
||||||
time timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
time timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
@ -71,7 +79,6 @@ CREATE INDEX idx_puser_id ON positions(user_id);
|
|||||||
-- Table structure for table `config`
|
-- Table structure for table `config`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS config;
|
|
||||||
CREATE TABLE config (
|
CREATE TABLE config (
|
||||||
name varchar(20) PRIMARY KEY,
|
name varchar(20) PRIMARY KEY,
|
||||||
value bytea NOT NULL
|
value bytea NOT NULL
|
||||||
@ -108,8 +115,6 @@ INSERT INTO config (name, value) VALUES
|
|||||||
-- Table structure for table `ol_layers`
|
-- Table structure for table `ol_layers`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS ol_layers;
|
|
||||||
|
|
||||||
CREATE TABLE ol_layers (
|
CREATE TABLE ol_layers (
|
||||||
id serial PRIMARY KEY,
|
id serial PRIMARY KEY,
|
||||||
name varchar(50) NOT NULL,
|
name varchar(50) NOT NULL,
|
||||||
|
@ -2,6 +2,17 @@
|
|||||||
-- Database: `ulogger`
|
-- Database: `ulogger`
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Drop tables if exist
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `positions`;
|
||||||
|
DROP TABLE IF EXISTS `tracks`;
|
||||||
|
DROP TABLE IF EXISTS `users`;
|
||||||
|
DROP TABLE IF EXISTS `config`;
|
||||||
|
DROP TABLE IF EXISTS `ol_layers`;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
@ -9,7 +20,6 @@
|
|||||||
-- Table structure for table `users`
|
-- Table structure for table `users`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `users`;
|
|
||||||
CREATE TABLE `users` (
|
CREATE TABLE `users` (
|
||||||
`id` integer PRIMARY KEY AUTOINCREMENT,
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
`login` varchar(15) NOT NULL UNIQUE,
|
`login` varchar(15) NOT NULL UNIQUE,
|
||||||
@ -23,7 +33,6 @@ CREATE TABLE `users` (
|
|||||||
-- Table structure for table `tracks`
|
-- Table structure for table `tracks`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `tracks`;
|
|
||||||
CREATE TABLE `tracks` (
|
CREATE TABLE `tracks` (
|
||||||
`id` integer PRIMARY KEY AUTOINCREMENT,
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
`user_id` integer NOT NULL,
|
`user_id` integer NOT NULL,
|
||||||
@ -39,7 +48,6 @@ CREATE INDEX `idx_user_id` ON `tracks`(`user_id`);
|
|||||||
-- Table structure for table `positions`
|
-- Table structure for table `positions`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `positions`;
|
|
||||||
CREATE TABLE `positions` (
|
CREATE TABLE `positions` (
|
||||||
`id` integer PRIMARY KEY AUTOINCREMENT,
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
@ -66,7 +74,6 @@ CREATE INDEX `idx_puser_id` ON `positions`(`user_id`);
|
|||||||
-- Table structure for table `config`
|
-- Table structure for table `config`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `config`;
|
|
||||||
CREATE TABLE `config` (
|
CREATE TABLE `config` (
|
||||||
`name` varchar(20) PRIMARY KEY,
|
`name` varchar(20) PRIMARY KEY,
|
||||||
`value` tinyblob NOT NULL
|
`value` tinyblob NOT NULL
|
||||||
@ -103,7 +110,6 @@ INSERT INTO `config` (`name`, `value`) VALUES
|
|||||||
-- Table structure for table `ol_layers`
|
-- Table structure for table `ol_layers`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `ol_layers`;
|
|
||||||
CREATE TABLE `ol_layers` (
|
CREATE TABLE `ol_layers` (
|
||||||
`id` integer PRIMARY KEY AUTOINCREMENT,
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
`name` varchar(50) NOT NULL,
|
`name` varchar(50) NOT NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user