2019-01-28 23:03:03 +01:00
|
|
|
--
|
|
|
|
-- Database: `ulogger`
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table `users`
|
|
|
|
--
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `users`;
|
|
|
|
CREATE TABLE `users` (
|
|
|
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
|
|
|
`login` varchar(15) NOT NULL UNIQUE,
|
2020-02-17 18:51:27 +01:00
|
|
|
`password` varchar(255) NOT NULL DEFAULT '',
|
|
|
|
`admin` integer NOT NULL DEFAULT 0
|
2019-01-28 23:03:03 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table `tracks`
|
|
|
|
--
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `tracks`;
|
|
|
|
CREATE TABLE `tracks` (
|
|
|
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
|
|
|
`user_id` integer NOT NULL,
|
|
|
|
`name` varchar(255) DEFAULT NULL,
|
|
|
|
`comment` varchar(1024) DEFAULT NULL,
|
|
|
|
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`)
|
|
|
|
);
|
|
|
|
CREATE INDEX `idx_user_id` ON `tracks`(`user_id`);
|
|
|
|
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Table structure for table `positions`
|
|
|
|
--
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `positions`;
|
|
|
|
CREATE TABLE `positions` (
|
|
|
|
`id` integer PRIMARY KEY AUTOINCREMENT,
|
|
|
|
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`user_id` integer NOT NULL,
|
|
|
|
`track_id` integer NOT NULL,
|
|
|
|
`latitude` double NOT NULL,
|
|
|
|
`longitude` double NOT NULL,
|
|
|
|
`altitude` double DEFAULT NULL,
|
|
|
|
`speed` double DEFAULT NULL,
|
|
|
|
`bearing` double DEFAULT NULL,
|
|
|
|
`accuracy` integer DEFAULT NULL,
|
|
|
|
`provider` varchar(100) DEFAULT NULL,
|
|
|
|
`comment` varchar(255) DEFAULT NULL,
|
2019-07-12 21:50:21 +02:00
|
|
|
`image` varchar(100) DEFAULT NULL,
|
2019-01-28 23:03:03 +01:00
|
|
|
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`),
|
|
|
|
FOREIGN KEY(`track_id`) REFERENCES `tracks`(`id`)
|
|
|
|
);
|
|
|
|
CREATE INDEX `idx_ptrack_id` ON `positions`(`track_id`);
|
|
|
|
CREATE INDEX `idx_puser_id` ON `positions`(`user_id`);
|
|
|
|
|
|
|
|
--
|
|
|
|
-- This will add default user admin with password admin
|
|
|
|
-- The password should be changed immediatelly after installation
|
|
|
|
-- Uncomment if needed
|
|
|
|
--
|
|
|
|
-- INSERT INTO `users` (`id`, `login`, `password`) VALUES
|
|
|
|
-- (1, 'admin', '$2y$10$7OvZrKgonVZM9lkzrTbiou.CVhO3HjPk5y0W9L68fVwPs/osBRIMq');
|