@padhariyavishal/nextpress-config
Version:
Nextpress configuration
163 lines (161 loc) • 8.31 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.categoryRelationshipTable = exports.categoryMetaTable = exports.categoryTable = exports.categoryTypesTableData = exports.categoryTypesTable = exports.collectionMetaTable = exports.collectionTable = exports.collecionTypesTableData = exports.collecionTypesTable = exports.collectionStatusTableData = exports.collectionStatusTable = exports.commentsMetaTable = exports.commentsTable = exports.usersTableData = exports.usersMetaTable = exports.usersTable = exports.userRolesTableData = exports.userRolesTable = exports.configurationTableData = exports.configurationTable = void 0;
const prefix = "np_";
exports.configurationTable = `
CREATE TABLE ${prefix}configuration (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
config_key varchar(255) NOT NULL,
config_value varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.configurationTableData = `
INSERT INTO ${prefix}configuration (id, config_key, config_value) VALUES
(1, 'app_name', 'nextpress-app'),
(2, 'app_title', 'NextPress APP'),
(3, 'app_description', NULL),
(4, 'user_can_register', '0'),
(5, 'app_email', NULL),
(6, 'enable_comments', '1'),
(7, 'mailserver_host', 'mail.example.com'),
(8, 'mailserver_username', 'login@example.com'),
(9, 'mailserver_password', 'password'),
(10, 'mailserver_port', '110'),
(11, 'collection_per_page', '10');
`;
exports.userRolesTable = `CREATE TABLE ${prefix}user_roles (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
role_name varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.userRolesTableData = `INSERT INTO ${prefix}user_roles (id, role_name) VALUES
(1, 'administrator'),
(2, 'editor'),
(3, 'subscriber');
`;
exports.usersTable = `CREATE TABLE ${prefix}users (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
username varchar(255) NOT NULL,
password varchar(60) NOT NULL,
user_email varchar(60) DEFAULT NULL,
user_role int(11) NOT NULL,
status int(1) NOT NULL,
created_at datetime NOT NULL DEFAULT current_timestamp(),
FOREIGN KEY (user_role) REFERENCES ${prefix}user_roles (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.usersMetaTable = `CREATE TABLE ${prefix}usermeta (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id int(11) NOT NULL,
meta_key varchar(255) DEFAULT NULL,
meta_value text DEFAULT NULL,
FOREIGN KEY (user_id) REFERENCES ${prefix}users (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
const usersTableData = (username, password) => {
const userData = `
INSERT INTO ${prefix}users (username,password,user_role,status) VALUES
('${username}','${password}',1,1);
`;
return { userData };
};
exports.usersTableData = usersTableData;
exports.commentsTable = `CREATE TABLE ${prefix}comments (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
author_name varchar(60) NOT NULL,
author_mail varchar(60) NOT NULL,
author_ip varchar(30) NOT NULL,
content longtext NOT NULL,
approved int(11) NOT NULL DEFAULT 1,
parent int(11) NOT NULL DEFAULT 0,
created_at datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.commentsMetaTable = `CREATE TABLE ${prefix}commentsmeta (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
comment_id int(11) NOT NULL,
meta_key varchar(255) NOT NULL,
meta_value varchar(255) DEFAULT NULL,
FOREIGN KEY (comment_id) REFERENCES ${prefix}comments (id) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.collectionStatusTable = `CREATE TABLE ${prefix}collection_status (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
status varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`;
exports.collectionStatusTableData = ` INSERT INTO ${prefix}collection_status (id, status) VALUES
(1, 'publish'),
(2, 'draft'),
(3, 'private'),
(4, 'trash');`;
exports.collecionTypesTable = `CREATE TABLE ${prefix}collection_types (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
name varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`;
exports.collecionTypesTableData = ` INSERT INTO ${prefix}collection_types (id, name) VALUES
(1, 'blog'),
(2, 'media'),
(3, 'page');`;
exports.collectionTable = `CREATE TABLE ${prefix}collections (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
author int(11) NOT NULL,
type int(11) NOT NULL,
status int(11) NOT NULL,
title varchar(255) NOT NULL,
content longtext DEFAULT NULL,
uri varchar(255) NOT NULL,
menu_order int(11) NOT NULL DEFAULT 0,
parent int(11) NOT NULL DEFAULT 0,
comment_id int(11) DEFAULT NULL,
created_at datetime NOT NULL DEFAULT current_timestamp(),
updated_at datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
FOREIGN KEY (author) REFERENCES ${prefix}users (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (status) REFERENCES ${prefix}collection_status (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (type) REFERENCES ${prefix}collection_types (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (comment_id) REFERENCES ${prefix}comments (id) ON DELETE SET NULL ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`;
exports.collectionMetaTable = `CREATE TABLE ${prefix}collectionmeta (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
collection_id int(11) NOT NULL,
meta_key varchar(255) DEFAULT NULL,
meta_value text DEFAULT NULL,
FOREIGN KEY (collection_id) REFERENCES ${prefix}collections (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.categoryTypesTable = `CREATE TABLE ${prefix}category_types (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
name varchar(60) NOT NULL,
collection_type_id int(11) NOT NULL,
description varchar(255) DEFAULT NULL,
FOREIGN KEY (collection_type_id) REFERENCES ${prefix}collection_types (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.categoryTypesTableData = ` INSERT INTO ${prefix}category_types (id, name, collection_type_id, description) VALUES
(1, 'category', 1, '');
`;
exports.categoryTable = `CREATE TABLE ${prefix}categories (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
category_type_id int(11) NOT NULL,
collection_id int(11) NOT NULL,
name varchar(60) NOT NULL,
uri varchar(60) NOT NULL,
created_at datetime NOT NULL DEFAULT current_timestamp(),
updated_at datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
FOREIGN KEY (category_type_id) REFERENCES ${prefix}category_types (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (collection_id) REFERENCES ${prefix}collections (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
`;
exports.categoryMetaTable = `CREATE TABLE ${prefix}categoriesmeta (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
category_id int(11) NOT NULL,
meta_key varchar(255) NOT NULL,
meta_value varchar(255) NOT NULL,
FOREIGN KEY (category_id) REFERENCES ${prefix}categories (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`;
exports.categoryRelationshipTable = `CREATE TABLE ${prefix}categories_relationship (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
category_id int(11) NOT NULL,
collection_id int(11) NOT NULL,
FOREIGN KEY (category_id) REFERENCES ${prefix}categories (id) ON DELETE CASCADE ON UPDATE CASCADE
FOREIGN KEY (collection_id) REFERENCES ${prefix}collections (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`;