更新脚本:增加Postgresql数据库脚本

This commit is contained in:
Argo-Surface 2019-01-20 16:24:44 +08:00
parent 7952b4a305
commit 1eeeac388d
3 changed files with 245 additions and 0 deletions

View File

@ -56,6 +56,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MySQL", "MySQL", "{084E2E94
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "UnitTest\UnitTest.csproj", "{CFE75C48-F9D5-403A-8419-D07939BBD769}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Postgresql", "Postgresql", "{6F61C2AC-84D4-48A9-8A48-680657CC8175}"
ProjectSection(SolutionItems) = preProject
DatabaseScripts\Postgresql\initData.sql = DatabaseScripts\Postgresql\initData.sql
DatabaseScripts\Postgresql\install.sql = DatabaseScripts\Postgresql\install.sql
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

View File

@ -0,0 +1,99 @@
DELETE From Users;
-- ADMIN/123789
ALTER SEQUENCE users_id_seq RESTART WITH 1;
INSERT INTO Users (UserName, Password, PassSalt, DisplayName, RegisterTime, ApprovedTime,ApprovedBy, Description) values ('Admin', 'Es7WVgNsJuELwWK8daCqufUBknCsSC0IYDphQZAiGOo=', 'W5vpBEOYRGHkQXatN0t+ECM/U8cHDuEgrq56+zZBk4J481xH', 'Administrator', now(), now(), 'system', '系统默认创建');
DELETE From Dicts;
ALTER SEQUENCE dicts_id_seq RESTART WITH 1;
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('菜单', '系统菜单', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('菜单', '外部菜单', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('应用程序', '未设置', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '网站标题', '后台管理系统', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '网站页脚', '2016 © 通用后台管理系统', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统通知', '用户注册', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统通知', '程序异常', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统通知', '数据库连接', '2', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('通知状态', '未处理', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('通知状态', '已处理', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('处理结果', '同意', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('处理结果', '拒绝', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('消息状态', '未读', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('消息状态', '已读', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('消息标签', '一般', '0', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('消息标签', '紧要', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('头像地址', '头像路径', '~/images/uploader/', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('头像地址', '头像文件', 'default.jpg', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站样式', '蓝色样式', 'blue.css', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站样式', '黑色样式', 'black.css', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('当前样式', '使用样式', 'blue.css', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '前台首页', '~/Home/Index', 0);
DELETE FROM Navigations;
ALTER SEQUENCE navigations_id_seq RESTART WITH 1;
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '后台管理', 10, 'fa fa-gear', '~/Admin/Index', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '个人中心', 20, 'fa fa-suitcase', '~/Admin/Profiles', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '返回前台', 30, 'fa fa-hand-o-left', '~/Home/Index', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '网站设置', 40, 'fa fa-fa', '~/Admin/Settings', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '菜单管理', 50, 'fa fa-dashboard', '~/Admin/Menus', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '用户管理', 60, 'fa fa-user', '~/Admin/Users', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '角色管理', 70, 'fa fa-sitemap', '~/Admin/Roles', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '部门管理', 80, 'fa fa-bank', '~/Admin/Groups', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '字典表维护', 90, 'fa fa-book', '~/Admin/Dicts', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '站内消息', 100, 'fa fa-envelope', '~/Admin/Messages', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '任务管理', 110, 'fa fa fa-tasks', '~/Admin/Tasks', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '通知管理', 120, 'fa fa-bell', '~/Admin/Notifications', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '系统日志', 130, 'fa fa-gears', '~/Admin/Logs', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '程序异常', 140, 'fa fa-cubes', '~/Admin/Exceptions', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (0, '工具集合', 160, 'fa fa-gavel', '#', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (currval('navigations_id_seq') - 1, '客户端测试', 10, 'fa fa-wrench', '~/Admin/Mobile', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (currval('navigations_id_seq') - 2, 'API文档', 10, 'fa fa-wrench', '~/swagger', '0');
INSERT INTO Navigations (ParentId, Name, "Order", Icon, Url, Category) VALUES (currval('navigations_id_seq') - 3, '图标集', 10, 'fa fa-dashboard', '~/Admin/FAIcon', '0');
DELETE FROM Groups;
ALTER SEQUENCE groups_id_seq RESTART WITH 1;
INSERT INTO Groups (ID, GroupName, Description) VALUES (1, 'Admin', '系统默认组');
DELETE FROM Roles;
ALTER SEQUENCE roles_id_seq RESTART WITH 1;
INSERT INTO Roles (RoleName, Description) VALUES ('Administrators', '系统管理员');
INSERT INTO Roles (RoleName, Description) VALUES ('Default', '默认用户,可访问前台页面');
DELETE FROM RoleGroup;
INSERT INTO RoleGroup (RoleID, GroupID) VALUES (1, 1);
DELETE FROM UserGroup;
INSERT INTO UserGroup (UserID, GroupID) VALUES (1, 1);
DELETE FROM UserRole;
INSERT INTO UserRole (UserID, RoleID) VALUES (1, 1);
INSERT INTO UserRole (UserID, RoleID) VALUES (1, 2);
DELETE FROM NavigationRole;
INSERT INTO NavigationRole (NavigationID, RoleID) SELECT ID, 1 FROM navigations;
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (1, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (2, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (3, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (10, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (16, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (17, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (18, 2);
INSERT INTO NavigationRole (NavigationID, RoleID) VALUES (19, 2);
-- Client Data
Delete From Dicts Where Category = '应用程序' and Code = '2';
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('应用程序', '测试平台', 2, 0);
Delete From Dicts Where Category = '测试平台';
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '网站标题', 'BA Client', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '网站页脚', '通用后台管理测试平台', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '个人中心地址', 'http://localhost:50852/Admin/Profiles', 1);
Insert into Dicts (Category, Name, Code, Define) values ('测试平台', '系统设置地址', 'http://localhost:50852/Admin/Settings', 1);
Delete from Navigations where Application = '2';
INSERT into Navigations (ParentId, Name, "Order", Icon, Url, Category, Application) VALUES (0, '首页', 10, 'fa fa-fa', '~/Home/Index', '1', 2);
INSERT into Navigations (ParentId, Name, "Order", Icon, Url, Category, Application) VALUES (0, '测试页面', 20, 'fa fa-fa', '#', '1', 2);
INSERT into Navigations (ParentId, Name, "Order", Icon, Url, Category, Application) VALUES (currval('navigations_id_seq') - 1, '关于', 10, 'fa fa-fa', '~/Home/About', '1', 2);
-- 菜单授权
DELETE FROM NavigationRole Where NavigationID in (Select ID From Navigations Where Application = '2');
INSERT INTO NavigationRole (NavigationID, RoleID) SELECT ID, 2 FROM Navigations Where Application = '2';

View File

@ -0,0 +1,140 @@
CREATE TABLE Users (
ID SERIAL PRIMARY KEY,
UserName VARCHAR (50) NOT NULL,
Password VARCHAR (50) NOT NULL,
PassSalt VARCHAR (50) NOT NULL,
DisplayName VARCHAR (50) NOT NULL,
RegisterTime DATE NOT NULL,
ApprovedTime DATE,
ApprovedBy VARCHAR (50),
Description VARCHAR (500) NOT NULL,
RejectedBy VARCHAR (50),
RejectedTime DATE,
RejectedReason VARCHAR (50),
Icon VARCHAR (50),
Css VARCHAR (50)
);
CREATE TABLE UserRole (
ID SERIAL PRIMARY KEY,
UserID INT NOT NULL,
RoleID INT NOT NULL
);
CREATE TABLE UserGroup(
ID SERIAL PRIMARY KEY,
UserID INT NOT NULL,
GroupID INT NOT NULL
);
CREATE TABLE Roles(
ID SERIAL PRIMARY KEY,
RoleName VARCHAR (50) NULL,
Description VARCHAR (500) NULL
);
CREATE TABLE RoleGroup(
ID SERIAL PRIMARY KEY,
RoleID INT NOT NULL,
GroupID INT NOT NULL
);
CREATE TABLE Notifications(
ID SERIAL PRIMARY KEY,
Category VARCHAR (50) NOT NULL,
Title VARCHAR (50) NOT NULL,
Content VARCHAR (50) NOT NULL,
RegisterTime DATE NOT NULL,
ProcessTime DATE NULL,
ProcessBy VARCHAR (50) NULL,
ProcessResult VARCHAR (50) NULL,
Status VARCHAR (50) DEFAULT 0
);
CREATE TABLE Navigations(
ID SERIAL PRIMARY KEY,
ParentId INT DEFAULT 0,
Name VARCHAR (50) NOT NULL,
"Order" INT NOT NULL DEFAULT 0,
Icon VARCHAR (50) DEFAULT 'fa fa-fa',
Url VARCHAR (4000) NULL,
Category VARCHAR (50) DEFAULT 0,
Target VARCHAR (10) DEFAULT '_self',
IsResource INT DEFAULT 0,
Application VARCHAR (200) DEFAULT 0
);
CREATE TABLE NavigationRole(
ID SERIAL PRIMARY KEY,
NavigationID INT NOT NULL,
RoleID INT NOT NULL
);
CREATE TABLE Logs(
ID SERIAL PRIMARY KEY,
CRUD VARCHAR (50) NOT NULL,
UserName VARCHAR (50) NOT NULL,
LogTime DATE NOT NULL,
ClientIp VARCHAR (15) NOT NULL,
ClientAgent VARCHAR (500) NOT NULL,
RequestUrl VARCHAR (500) NOT NULL
);
CREATE TABLE Groups(
ID SERIAL PRIMARY KEY,
GroupName VARCHAR (50) NULL,
Description VARCHAR (500) NULL
);
CREATE TABLE Exceptions(
ID SERIAL PRIMARY KEY,
AppDomainName VARCHAR (50) NOT NULL,
ErrorPage VARCHAR (50) NOT NULL,
UserID VARCHAR (50) NULL,
UserIp VARCHAR (15) NULL,
ExceptionType TEXT NOT NULL,
Message TEXT NOT NULL,
StackTrace TEXT NULL,
LogTime DATE NOT NULL
);
CREATE TABLE Dicts(
ID SERIAL PRIMARY KEY,
Category VARCHAR (50) NOT NULL,
Name VARCHAR (50) NOT NULL,
Code VARCHAR (500) NOT NULL,
Define INT NOT NULL DEFAULT 1
);
CREATE TABLE Messages(
ID SERIAL PRIMARY KEY,
Title VARCHAR (50) NOT NULL,
Content VARCHAR (500) NOT NULL,
"From" VARCHAR (50) NOT NULL,
"To" VARCHAR (50) NOT NULL,
SendTime DATE NOT NULL,
Status VARCHAR (50) NOT NULL,
Flag INT DEFAULT 0,
IsDelete INT DEFAULT 0,
Label VARCHAR (50)
);
CREATE TABLE Tasks(
ID SERIAL PRIMARY KEY,
TaskName VARCHAR (500) NOT NULL,
AssignName VARCHAR (50) NOT NULL,
UserName VARCHAR (50) NOT NULL,
TaskTime INT NOT NULL,
TaskProgress INT NOT NULL,
AssignTime DATE NOT NULL
);
CREATE TABLE RejectUsers(
ID SERIAL PRIMARY KEY,
UserName VARCHAR (50) NOT NULL,
DisplayName VARCHAR (50) NOT NULL,
RegisterTime DATE NOT NULL,
RejectedBy VARCHAR (50) NULL,
RejectedTime DATE NULL,
RejectedReason VARCHAR (50) NULL
);