USE [master]
GO
/****** Object:  Database [PHP_Trend]    Script Date: 2023/1/7 下午 10:47:51 ******/
CREATE DATABASE [PHP_Trend]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'PHP_Trend', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\PHP_Trend.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
 LOG ON 
( NAME = N'PHP_Trend_log', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\PHP_Trend_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
ALTER DATABASE [PHP_Trend] SET COMPATIBILITY_LEVEL = 140
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [PHP_Trend].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [PHP_Trend] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [PHP_Trend] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [PHP_Trend] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [PHP_Trend] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [PHP_Trend] SET ARITHABORT OFF 
GO
ALTER DATABASE [PHP_Trend] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [PHP_Trend] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [PHP_Trend] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [PHP_Trend] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [PHP_Trend] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [PHP_Trend] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [PHP_Trend] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [PHP_Trend] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [PHP_Trend] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [PHP_Trend] SET  DISABLE_BROKER 
GO
ALTER DATABASE [PHP_Trend] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [PHP_Trend] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [PHP_Trend] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [PHP_Trend] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [PHP_Trend] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [PHP_Trend] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [PHP_Trend] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [PHP_Trend] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [PHP_Trend] SET  MULTI_USER 
GO
ALTER DATABASE [PHP_Trend] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [PHP_Trend] SET DB_CHAINING OFF 
GO
ALTER DATABASE [PHP_Trend] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [PHP_Trend] SET TARGET_RECOVERY_TIME = 60 SECONDS 
GO
ALTER DATABASE [PHP_Trend] SET DELAYED_DURABILITY = DISABLED 
GO
ALTER DATABASE [PHP_Trend] SET QUERY_STORE = OFF
GO
USE [PHP_Trend]
GO
/****** Object:  Table [dbo].[users]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[users](
	[user_id] [varchar](50) NOT NULL,
	[user_name] [nvarchar](50) NOT NULL,
	[enabled] [bit] NOT NULL,
	[priv_no] [int] NOT NULL,
	[password] [varchar](50) NOT NULL,
	[email] [varchar](50) NULL,
 CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED 
(
	[user_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[roles]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[roles](
	[role_id] [varchar](50) NOT NULL,
	[role_name] [nvarchar](200) NOT NULL,
	[enabled] [bit] NOT NULL,
 CONSTRAINT [PK_roles] PRIMARY KEY CLUSTERED 
(
	[role_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[roles_users]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[roles_users](
	[role_id] [varchar](50) NOT NULL,
	[user_id] [varchar](50) NOT NULL,
 CONSTRAINT [PK_roles_users] PRIMARY KEY CLUSTERED 
(
	[role_id] ASC,
	[user_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  View [dbo].[v_roles_users]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_roles_users]
AS
SELECT          dbo.roles.role_id, dbo.roles.role_name, dbo.users.user_id, dbo.users.user_name, 
                            dbo.users.email
FROM              dbo.roles INNER JOIN
                            dbo.roles_users ON dbo.roles.role_id = dbo.roles_users.role_id INNER JOIN
                            dbo.users ON dbo.roles_users.user_id = dbo.users.user_id
WHERE          dbo.roles.enabled = 1 AND dbo.users.enabled = 1
UNION
SELECT          dbo.roles.role_id, dbo.roles.role_name, dbo.users.user_id, dbo.users.user_name, 
                            dbo.users.email
FROM              dbo.roles CROSS JOIN
                            dbo.users
WHERE          dbo.roles.enabled = 1 AND dbo.users.enabled = 1 AND dbo.roles.role_id = 'user'
GO
/****** Object:  Table [dbo].[Station_Spec]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Station_Spec](
	[STN] [int] NULL,
	[Name] [nvarchar](255) NULL,
	[City] [nvarchar](255) NULL,
	[City_Name] [nvarchar](255) NULL,
	[Section_Name] [nvarchar](255) NULL,
	[Section] [nvarchar](255) NULL,
	[Area_Name] [nvarchar](255) NULL,
	[Area] [nvarchar](255) NULL,
	[Capacity] [float] NULL,
	[Inverter] [nvarchar](255) NULL,
	[Device_Def] [nvarchar](255) NULL,
	[Weather_Code] [nvarchar](255) NULL,
	[Model] [nvarchar](255) NULL,
	[Module_No] [nvarchar](255) NULL,
	[Title_PNG] [nvarchar](255) NULL,
	[Tag_PNG] [nvarchar](255) NULL,
	[Area_Main_PNG] [nvarchar](255) NULL,
	[NO] [nvarchar](255) NULL,
	[Customer_Code] [float] NULL,
	[Order_Number] [float] NULL,
	[PPA_contracts] [nvarchar](255) NULL,
	[Unit_Price] [float] NULL,
	[Address] [nvarchar](255) NULL,
	[Record_Date] [float] NULL,
	[Price_Rate] [float] NULL,
	[Name1] [nvarchar](128) NULL,
	[Note] [nvarchar](max) NULL,
	[Insert_day] [date] NULL,
	[STN_2] [nvarchar](100) NULL,
	[lng] [varchar](50) NULL,
	[lat] [varchar](50) NULL,
	[Online] [int] NULL,
	[BrokenLine] [int] NULL,
	[BrokenTime] [datetime] NULL,
	[BrokenInv] [varchar](500) NULL,
	[ACMeter] [bit] NULL,
	[ACMeterCount] [int] NULL,
	[Solar_Version] [varchar](50) NULL,
	[Sales_Rep] [varchar](50) NULL,
	[Special_Station] [varchar](50) NULL,
	[SimCard] [nvarchar](50) NULL,
	[Remark] [nvarchar](250) NULL,
	[RecalculateBy] [tinyint] NOT NULL,
	[IsV2] [bit] NOT NULL,
	[LatestCmbTime] [datetime] NULL,
	[INV_PR_Limit] [float] NULL,
	[MPPT_RA_Limit] [float] NULL,
	[INV_PR_Limit_Days] [int] NULL,
	[MPPT_RA_Limit_Days] [int] NULL,
	[AI_Solar_Panel_Clear_Days] [int] NULL,
	[INV_PR_Device_Limit] [float] NULL,
	[AttentionItems] [nvarchar](max) NULL,
	[STN_Order] [int] NOT NULL,
	[Al_INV] [bit] NOT NULL,
	[Al_SunshineTemp] [bit] NOT NULL,
	[Al_Protected] [bit] NOT NULL,
	[Al_Factory] [bit] NOT NULL,
	[Al_DAB] [bit] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[roles_station_spec]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[roles_station_spec](
	[role_id] [varchar](50) NOT NULL,
	[STN] [int] NOT NULL,
 CONSTRAINT [PK_roles_station_spec] PRIMARY KEY CLUSTERED 
(
	[role_id] ASC,
	[STN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  View [dbo].[v_roles_stations]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_roles_stations]
AS
SELECT          dbo.roles.*, dbo.Station_Spec.*
FROM              dbo.roles INNER JOIN
                            dbo.roles_station_spec ON dbo.roles.role_id = dbo.roles_station_spec.role_id INNER JOIN
                            dbo.Station_Spec ON dbo.roles_station_spec.STN = dbo.Station_Spec.STN
WHERE          (dbo.Station_Spec.Online = 1) AND (dbo.roles.enabled = 1)
UNION
SELECT          dbo.roles.*, dbo.Station_Spec.*
FROM              dbo.roles CROSS JOIN
                            dbo.Station_Spec
WHERE          (dbo.Station_Spec.Online = 1) AND (dbo.roles.enabled = 1) AND (role_id in('admin','all_stn'))
GO
/****** Object:  Table [dbo].[roles_menu]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[roles_menu](
	[role_id] [varchar](50) NOT NULL,
	[menu_id] [varchar](50) NOT NULL,
 CONSTRAINT [PK_roles_menu] PRIMARY KEY CLUSTERED 
(
	[role_id] ASC,
	[menu_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[menu]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[menu](
	[menu_id] [varchar](30) NOT NULL,
	[menu_name] [nvarchar](50) NOT NULL,
	[enabled] [bit] NOT NULL,
 CONSTRAINT [PK_menu] PRIMARY KEY CLUSTERED 
(
	[menu_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  View [dbo].[v_roles_menu]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_roles_menu]
AS
SELECT          dbo.roles.role_id, dbo.roles.role_name, dbo.menu.menu_id, dbo.menu.menu_name
FROM              dbo.roles INNER JOIN
                            dbo.roles_menu ON dbo.roles.role_id = dbo.roles_menu.role_id INNER JOIN
                            dbo.menu ON dbo.roles_menu.menu_id = dbo.menu.menu_id
WHERE          (dbo.menu.enabled = 1)
UNION
SELECT          dbo.roles.role_id, dbo.roles.role_name, dbo.menu.menu_id, dbo.menu.menu_name
FROM              dbo.roles CROSS JOIN
                            dbo.menu
WHERE          (dbo.menu.enabled = 1) AND (role_id IN ('admin', 'all_menu'))
GO
/****** Object:  View [dbo].[v_roles_users_menu]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_roles_users_menu]
AS
SELECT          dbo.v_roles_menu.menu_id, dbo.v_roles_users.*
FROM              dbo.v_roles_menu INNER JOIN
                            dbo.v_roles_users ON dbo.v_roles_menu.role_id = dbo.v_roles_users.role_id
GO
/****** Object:  View [dbo].[v_roles_users_stations]    Script Date: 2023/1/7 下午 10:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[v_roles_users_stations]
AS
SELECT          dbo.v_roles_stations.*, dbo.v_roles_users.user_id, dbo.v_roles_users.user_name
FROM              dbo.v_roles_stations INNER JOIN
                            dbo.v_roles_users ON dbo.v_roles_stations.role_id = dbo.v_roles_users.role_id
GO
INSERT [dbo].[menu] ([menu_id], [menu_name], [enabled]) VALUES (N'b', N'b', 1)
INSERT [dbo].[menu] ([menu_id], [menu_name], [enabled]) VALUES (N'index', N'INDEX', 1)
INSERT [dbo].[menu] ([menu_id], [menu_name], [enabled]) VALUES (N'test', N'test', 1)
GO
INSERT [dbo].[roles] ([role_id], [role_name], [enabled]) VALUES (N'admin', N'Admin', 1)
INSERT [dbo].[roles] ([role_id], [role_name], [enabled]) VALUES (N'all_menu', N'All Menu', 1)
INSERT [dbo].[roles] ([role_id], [role_name], [enabled]) VALUES (N'all_stn', N'All Station', 1)
INSERT [dbo].[roles] ([role_id], [role_name], [enabled]) VALUES (N'user', N'User', 1)
GO
INSERT [dbo].[roles_station_spec] ([role_id], [STN]) VALUES (N'user', 1)
GO
INSERT [dbo].[roles_users] ([role_id], [user_id]) VALUES (N'admin', N'sunware')
INSERT [dbo].[roles_users] ([role_id], [user_id]) VALUES (N'all_menu', N'all')
INSERT [dbo].[roles_users] ([role_id], [user_id]) VALUES (N'all_stn', N'all')
GO
INSERT [dbo].[Station_Spec] ([STN], [Name], [City], [City_Name], [Section_Name], [Section], [Area_Name], [Area], [Capacity], [Inverter], [Device_Def], [Weather_Code], [Model], [Module_No], [Title_PNG], [Tag_PNG], [Area_Main_PNG], [NO], [Customer_Code], [Order_Number], [PPA_contracts], [Unit_Price], [Address], [Record_Date], [Price_Rate], [Name1], [Note], [Insert_day], [STN_2], [lng], [lat], [Online], [BrokenLine], [BrokenTime], [BrokenInv], [ACMeter], [ACMeterCount], [Solar_Version], [Sales_Rep], [Special_Station], [SimCard], [Remark], [RecalculateBy], [IsV2], [LatestCmbTime], [INV_PR_Limit], [MPPT_RA_Limit], [INV_PR_Limit_Days], [MPPT_RA_Limit_Days], [AI_Solar_Panel_Clear_Days], [INV_PR_Device_Limit], [AttentionItems], [STN_Order], [Al_INV], [Al_SunshineTemp], [Al_Protected], [Al_Factory], [Al_DAB]) VALUES (1, N'TEST1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, 0.8, 0.8, 0, 0, 0, 1, NULL, 0, 0, 0, 0, 0, 0)
INSERT [dbo].[Station_Spec] ([STN], [Name], [City], [City_Name], [Section_Name], [Section], [Area_Name], [Area], [Capacity], [Inverter], [Device_Def], [Weather_Code], [Model], [Module_No], [Title_PNG], [Tag_PNG], [Area_Main_PNG], [NO], [Customer_Code], [Order_Number], [PPA_contracts], [Unit_Price], [Address], [Record_Date], [Price_Rate], [Name1], [Note], [Insert_day], [STN_2], [lng], [lat], [Online], [BrokenLine], [BrokenTime], [BrokenInv], [ACMeter], [ACMeterCount], [Solar_Version], [Sales_Rep], [Special_Station], [SimCard], [Remark], [RecalculateBy], [IsV2], [LatestCmbTime], [INV_PR_Limit], [MPPT_RA_Limit], [INV_PR_Limit_Days], [MPPT_RA_Limit_Days], [AI_Solar_Panel_Clear_Days], [INV_PR_Device_Limit], [AttentionItems], [STN_Order], [Al_INV], [Al_SunshineTemp], [Al_Protected], [Al_Factory], [Al_DAB]) VALUES (2, N'TEST2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, 0.8, 0.8, 0, 0, 0, 1, NULL, 0, 0, 0, 0, 0, 0)
GO
INSERT [dbo].[users] ([user_id], [user_name], [enabled], [priv_no], [password], [email]) VALUES (N'all', N'all', 1, 0, N'all', NULL)
INSERT [dbo].[users] ([user_id], [user_name], [enabled], [priv_no], [password], [email]) VALUES (N'sunware', N'sunware', 1, 3, N'sun', NULL)
INSERT [dbo].[users] ([user_id], [user_name], [enabled], [priv_no], [password], [email]) VALUES (N'test1', N'test1', 1, 0, N'test1', NULL)
INSERT [dbo].[users] ([user_id], [user_name], [enabled], [priv_no], [password], [email]) VALUES (N'test2', N'test2', 1, 0, N'test2', NULL)
GO
ALTER TABLE [dbo].[menu] ADD  CONSTRAINT [DF_menu_enabled]  DEFAULT ((1)) FOR [enabled]
GO
ALTER TABLE [dbo].[roles] ADD  CONSTRAINT [DF_roles_enabled]  DEFAULT ((1)) FOR [enabled]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_RecalculateBy]  DEFAULT ((1)) FOR [RecalculateBy]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_IsV2]  DEFAULT ((1)) FOR [IsV2]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_INV_PR_Limit]  DEFAULT ((0.8)) FOR [INV_PR_Limit]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_MPPT_RA_Limit]  DEFAULT ((0.8)) FOR [MPPT_RA_Limit]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_INV_PR_Limit_Days]  DEFAULT ((0)) FOR [INV_PR_Limit_Days]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_MPPT_RA_Limit_Days]  DEFAULT ((0)) FOR [MPPT_RA_Limit_Days]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_AI_Solar_Panel_Clear_Days]  DEFAULT ((0)) FOR [AI_Solar_Panel_Clear_Days]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_AI_Solar_Panel_Clear_Device_Limit]  DEFAULT ((1)) FOR [INV_PR_Device_Limit]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_STN_Order]  DEFAULT ((0)) FOR [STN_Order]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_Al_INV]  DEFAULT ((0)) FOR [Al_INV]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_Al_SunshineTemp]  DEFAULT ((0)) FOR [Al_SunshineTemp]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_Al_Protected]  DEFAULT ((0)) FOR [Al_Protected]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_Al_Factory]  DEFAULT ((0)) FOR [Al_Factory]
GO
ALTER TABLE [dbo].[Station_Spec] ADD  CONSTRAINT [DF_Station_Spec_Al_Dab]  DEFAULT ((0)) FOR [Al_DAB]
GO
ALTER TABLE [dbo].[users] ADD  CONSTRAINT [DF_users_enabled]  DEFAULT ((1)) FOR [enabled]
GO
ALTER TABLE [dbo].[users] ADD  CONSTRAINT [DF_users_priv_no]  DEFAULT ((0)) FOR [priv_no]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_menu'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_menu'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_stations'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_stations'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_users'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_users'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "v_roles_menu"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 136
               Right = 203
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "v_roles_users"
            Begin Extent = 
               Top = 6
               Left = 241
               Bottom = 136
               Right = 406
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_users_menu'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_users_menu'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "v_roles_stations"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 136
               Right = 274
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "v_roles_users"
            Begin Extent = 
               Top = 6
               Left = 312
               Bottom = 136
               Right = 477
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_users_stations'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_roles_users_stations'
GO
USE [master]
GO
ALTER DATABASE [PHP_Trend] SET  READ_WRITE 
GO
