﻿--Migration
truncate table T_ORARENDTELJES
go

alter table T_ORARENDTELJES drop constraint PK_OrarendTeljes
go

alter table T_ORARENDTELJES
    alter column C_DATUM date not null

alter table T_ORARENDTELJES
    alter column C_NAPDATUMA date null

alter table T_ORARENDTELJES
    alter column C_ORAERVENYESSEGKEZDETE date not null

alter table T_ORARENDTELJES
    alter column C_ORAERVENYESSEGVEGE date not null

alter table T_ORARENDTELJES
    alter column C_ORAKEZDETE time not null

alter table T_ORARENDTELJES
    alter column C_ORAVEGE time not null

alter table T_ORARENDTELJES
    alter column C_ORASZAM tinyint null

alter table T_ORARENDTELJES
    alter column C_INTEZMENYID smallint not null

alter table T_ORARENDTELJES
    alter column C_TANEVID smallint not null

alter table T_ORARENDTELJES
    alter column C_HETSORSZAMA tinyint null

alter table T_ORARENDTELJES
    add CREATED smalldatetime not null default (GETDATE())

alter table T_ORARENDTELJES
    add LASTCHANGED smalldatetime not null default (GETDATE())
go

exec dev.uspCreateSchemaViews 'T_ORARENDTELJES';
go

DROP INDEX IF EXISTS [NCI_Felhasznalo_IntezmenyId_TanevId_Neme] ON [dbo].[T_FELHASZNALO]
GO

CREATE NONCLUSTERED INDEX [NCI_Felhasznalo_IntezmenyId_TanevId_Neme] ON [dbo].[T_FELHASZNALO]
(
	[C_INTEZMENYID] ASC,
	[C_TANEVID] ASC,
	[C_NEME] ASC
)
INCLUDE(C_NYOMTATASINEV, C_IDPEGYEDIAZONOSITO)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY]
GO

alter table T_ORARENDTELJES
    add constraint PK_OrarendTeljes primary key clustered (C_INTEZMENYID, C_TANEVID, C_DATUM, C_ORARENDIORAID)
with (fillfactor = 100, data_compression = row)
go