IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Technic]'))
begin
	create table Technic
	(Id int not null identity(1,1) primary key,	 
	Name nvarchar(50)not null,
	Memo nvarchar(500) null	
	)
	
	create table MaterialTechnic 
	(Id int not null identity(1,1) primary key,
	MaterialId int not null foreign key references Material(Id),
	TechnicId int not null foreign key references Technic(Id),
	SailPrice numeric(18,4) not null,
	FactoryPrice numeric(18,4) not null)
	
	alter table OrderDetail add Technic nvarchar(max) null
	alter table OrderDetail add TechnicText nvarchar(max) null
	
	alter table FactoryOrderDetail add Technic nvarchar(max) null
	alter table FactoryOrderDetail add TechnicText nvarchar(max) null 
	
	alter table QuotationDetail add Technic nvarchar(max) null
	alter table QuotationDetail add TechnicText nvarchar(max) null 

	insert into Technic(Name,Memo)
		values
	('烫金',''),
	('双面哑膜',''),
	('起鼓',''),
	('压凹','')  

end
go


update FactoryOrder set  TemplateType=1,TemplateNo=(select top 1 TemplateNo from OrderTemplate order by CreateTime desc) where TemplateType=0
go

update configuration set SettingValue='4.9.1' where SettingName='DatabaseVersion'