Walkthrough: Extending the CRT to add customer preference data for Retail clients [AX 2012]

Updated: April 30, 2014

Applies To: Microsoft Dynamics AX 2012 R3

To add the RetailCustPreferences table to the Commerce Runtime (CRT), you can make the modifications in the CRT yourself or you can add code to and re-run CommerceRuntimeScripts.sql. This topic describes the modifications and includes the entire text of CommerceRuntimeScripts.sql.

These walkthroughs illustrate adding a field to a retail channel that enables customers to opt in to receive special offers by email. In this scenario, the retailer wants to indicate whether customers wish to receive email about special offers, either in an online store or in a modern POS client. The walkthroughs should be completed in the following order:

  1. Walkthrough: Adding a table for customer preferences to the AX 2012 database

  2. Walkthrough: Extending the CRT to add customer preference data for Retail clients

  3. Walkthrough: Extending retail data distribution infrastructure for customer preferences

  4. Walkthrough: Adding customer preferences to the Retail online sample store (online store only)

In the CRT, each entity is represented by a key-value pair. The key has the name of the column name in the table or view. The value is the value of the field for that column in the view. When you create the new fields in the CustomersView, the new key-value pair is included in the property bag. For more information see Customize the Data in a Commerce Entity.

Next, you will modify the stored procedure associated with the CustomersView view. This enables writing the data back to Microsoft Dynamics AX.

Dn720790.collapse_all(en-us,AX.60).gifCreate the new table in the channel database for the CRT to use

  1. Open Microsoft SQL Server Management Studio.

  2. In Object Explorer, expand the database node for and then expand the Tables node.

  3. Scroll down to the RetailCustPreferences table. Right-click the table, point to Script table as, then point to CREATE to, and then click New Query Editor Window.

  4. Go to the top line of the generated script and change the USE statement to the name of the channel database (aka the CRT database). The default name for this database after you install Microsoft Dynamics AX 2012 R3 is AxRetailSP. If that is the name of your channel database, the following example illustrates the USE statement.

    USE [AxRetailSP]

  5. Remove the PARTITION field.

  6. Change all instances of dbo to ax for the field names.

  7. Click Execute or press F5 to run the script.

Dn720790.collapse_all(en-us,AX.60).gifModify the CustomersView view in the channel database

You must add the EmailOptIn field to the CustomersView view in the channel database to make the new field available in the Retail online sample store.

  1. Open Microsoft SQL Server Management Studio. You must be logged on to the computer with the account that has permissions to modify the Retail databases.

  2. In Object Explorer, expand the database node for your channel database. The default name for this database after you install Microsoft Dynamics AX 2012 R3 is AxRetailSP.

  3. Expand the Views node and right-click dbo.Customersview.

  4. Click Script View as, ALTER to, New Query Editor Window.

  5. Add the following lines to the query to include the EmailOptIn field in the CustomersView.

    (SELECT    TOP (1) EMAILOPTIN
          FROM          dbo.RetailCustPreferences
          WHERE      (ACCOUNTNUM = dbo.CUSTTABLE.ACCOUNTNUM)) AS EmailOptIn, 
    
    
  6. Save your changes and re-run the query.

You run jobs to synchronize data from AX 2012 to the CRT. For more information, see Configure jobs and subjobs in Retail Scheduler.

In the AX 2012 Distribution schedule form, create a subjob under the Customer job for RetailCustPreferences. Fun the jobs that synchronize initial data in AX 2012 to the distribution location. For more information see Configure table distribution settings for Retail data and Configure and schedule retail data distribution.

This section contains the entire contents of CommerceRuntimeScripts.sql. There are four places where code has been inserted. Search for SDKSAMPLE_CUSTOMERPREFERENCES to find them.

Dn720790.collapse_all(en-us,AX.60).gifCode

-- SAMPLE CODE NOTICE
--
-- THIS SAMPLE CODE IS MADE AVAILABLE AS IS.  MICROSOFT MAKES NO WARRANTIES, WHETHER EXPRESS OR IMPLIED, OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY OR COMPLETENESS OF
-- RESPONSES, OF RESULTS, OR CONDITIONS OF MERCHANTABILITY.  THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SAMPLE CODE REMAINS WITH THE USER.  NO TECHNICAL
-- SUPPORT IS PROVIDED.  YOU MAY NOT DISTRIBUTE THIS CODE UNLESS YOU HAVE A LICENSE AGREEMENT WITH MICROSOFT THAT ALLOWS YOU TO DO SO.
-- Create the database schemas
IF NOT EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'ax')
BEGIN
  PRINT 'Creating AX database schema ..'
  EXECUTE('CREATE SCHEMA ax');
END;

IF NOT EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'crt')
BEGIN
  PRINT 'Creating CRT database schema ..'
  EXECUTE('CREATE SCHEMA crt');
END;

-- Creating role UsersRole
PRINT N'Creating role UsersRole';

GO

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'UsersRole' AND type = 'R')
BEGIN
    CREATE ROLE [UsersRole] AUTHORIZATION [dbo]
END
IF (@@ERROR != 0)
    PRINT N'FAILED to create role UsersRole.'

GO
PRINT N'Finished creating role UsersRole'
GO


-- Creating role PublishersRole
PRINT N'Creating role PublishersRole';

GO

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'PublishersRole' AND type = 'R')
BEGIN
    CREATE ROLE [PublishersRole] AUTHORIZATION [dbo]
END
IF (@@ERROR != 0)
    PRINT N'FAILED to create role PublishersRole.'

GO
PRINT N'Finished creating role PublishersRole'
GO


-- Creating role DataSyncUsersRole
PRINT N'Creating role DataSyncUsersRole';

GO

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'DataSyncUsersRole' AND type = 'R')
BEGIN
    CREATE ROLE [DataSyncUsersRole] AUTHORIZATION [dbo]
END
IF (@@ERROR != 0)
    PRINT N'FAILED to create role DataSyncUsersRole.'

GO
PRINT N'Finished creating role DataSyncUsersRole'
GO


-- Creating role db_executor
PRINT N'Creating role db_executor';

GO

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'db_executor' AND type = 'R')
BEGIN
    CREATE ROLE [db_executor] AUTHORIZATION [dbo]
END
IF (@@ERROR != 0)
    PRINT N'FAILED to create role db_executor.'

GO
PRINT N'Finished creating role db_executor'
GO

GRANT EXECUTE TO [db_executor]
GO
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ACCOUNTANT_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ACCOUNTANT_BR](
[RECID] [bigint] NOT NULL,
[CNPJNUM_BR] [nvarchar](20) NOT NULL,
[CPFNUM_BR] [nvarchar](20) NOT NULL,
[CRCNUM_BR] [nvarchar](20) NOT NULL,
[NAME] [nvarchar](100) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1701316395_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1701316395_1138566887] UNIQUE NONCLUSTERED 
(
[CPFNUM_BR] ASC,
[CRCNUM_BR] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANT_BR_CNPJNUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANT_BR] ADD  CONSTRAINT [DF_ACCOUNTANT_BR_CNPJNUM_BR]  DEFAULT ('') FOR [CNPJNUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANT_BR_CPFNUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANT_BR] ADD  CONSTRAINT [DF_ACCOUNTANT_BR_CPFNUM_BR]  DEFAULT ('') FOR [CPFNUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANT_BR_CRCNUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANT_BR] ADD  CONSTRAINT [DF_ACCOUNTANT_BR_CRCNUM_BR]  DEFAULT ('') FOR [CRCNUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANT_BR_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANT_BR] ADD  CONSTRAINT [DF_ACCOUNTANT_BR_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ACCOUNTANT_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ACCOUNTANTLOGISTICSLOCATION_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR](
[RECID] [bigint] NOT NULL,
[ACCOUNTANT] [bigint] NOT NULL,
[ISDEFAULT] [int] NOT NULL,
[ISPOSTALADDRESS] [int] NOT NULL,
[ISPRIMARY] [int] NOT NULL,
[ISPRIVATE] [int] NOT NULL,
[LOCATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1306553661_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1306553661_1643352582] UNIQUE NONCLUSTERED 
(
[ACCOUNTANT] ASC,
[LOCATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATION_BR_ACCOUNTANT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATION_BR_ACCOUNTANT]  DEFAULT ((0)) FOR [ACCOUNTANT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISDEFAULT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISDEFAULT]  DEFAULT ((0)) FOR [ISDEFAULT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISPOSTALADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISPOSTALADDRESS]  DEFAULT ((0)) FOR [ISPOSTALADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISPRIMARY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISPRIMARY]  DEFAULT ((0)) FOR [ISPRIMARY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISPRIVATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATION_BR_ISPRIVATE]  DEFAULT ((0)) FOR [ISPRIVATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATION_BR_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATION_BR_LOCATION]  DEFAULT ((0)) FOR [LOCATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ACCOUNTANTLOGISTICSLOCATION_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ACCOUNTANTLOGISTICSLOCATIONROLE_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ACCOUNTANTLOGISTICSLOCATIONROLE_BR](
[RECID] [bigint] NOT NULL,
[ACCOUNTANTLOGISTICSLOCATION] [bigint] NOT NULL,
[LOCATIONROLE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1576658753_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1576658753_-2080191547] UNIQUE NONCLUSTERED 
(
[LOCATIONROLE] ASC,
[ACCOUNTANTLOGISTICSLOCATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATIONROLE_BR_ACCOUNTANTLOGISTICSLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATIONROLE_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATIONROLE_BR_ACCOUNTANTLOGISTICSLOCATION]  DEFAULT ((0)) FOR [ACCOUNTANTLOGISTICSLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ACCOUNTANTLOGISTICSLOCATIONROLE_BR_LOCATIONROLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ACCOUNTANTLOGISTICSLOCATIONROLE_BR] ADD  CONSTRAINT [DF_ACCOUNTANTLOGISTICSLOCATIONROLE_BR_LOCATIONROLE]  DEFAULT ((0)) FOR [LOCATIONROLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ACCOUNTANTLOGISTICSLOCATIONROLE_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[BRAZILPARAMETERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[BRAZILPARAMETERS](
[RECID] [bigint] NOT NULL,
[APPROXTAXVALUESOURCE] [nvarchar](60) NOT NULL,
[KEY] [int] NOT NULL,
[LINKEDFISCALDOCUMENTMODEL02COFINS] [nvarchar](10) NOT NULL,
[LINKEDFISCALDOCUMENTMODEL02ICMS] [nvarchar](10) NOT NULL,
[LINKEDFISCALDOCUMENTMODEL02PIS] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1632568128_-1273337705] PRIMARY KEY CLUSTERED 
(
[KEY] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_BRAZILPARAMETERS_APPROXTAXVALUESOURCE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[BRAZILPARAMETERS] ADD  CONSTRAINT [DF_BRAZILPARAMETERS_APPROXTAXVALUESOURCE]  DEFAULT ('') FOR [APPROXTAXVALUESOURCE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_BRAZILPARAMETERS_KEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[BRAZILPARAMETERS] ADD  CONSTRAINT [DF_BRAZILPARAMETERS_KEY]  DEFAULT ((0)) FOR [KEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_BRAZILPARAMETERS_LINKEDFISCALDOCUMENTMODEL02COFINS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[BRAZILPARAMETERS] ADD  CONSTRAINT [DF_BRAZILPARAMETERS_LINKEDFISCALDOCUMENTMODEL02COFINS]  DEFAULT ('') FOR [LINKEDFISCALDOCUMENTMODEL02COFINS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_BRAZILPARAMETERS_LINKEDFISCALDOCUMENTMODEL02ICMS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[BRAZILPARAMETERS] ADD  CONSTRAINT [DF_BRAZILPARAMETERS_LINKEDFISCALDOCUMENTMODEL02ICMS]  DEFAULT ('') FOR [LINKEDFISCALDOCUMENTMODEL02ICMS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_BRAZILPARAMETERS_LINKEDFISCALDOCUMENTMODEL02PIS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[BRAZILPARAMETERS] ADD  CONSTRAINT [DF_BRAZILPARAMETERS_LINKEDFISCALDOCUMENTMODEL02PIS]  DEFAULT ('') FOR [LINKEDFISCALDOCUMENTMODEL02PIS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[BRAZILPARAMETERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[COMPANYINFO]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[COMPANYINFO](
[RECID] [bigint] NOT NULL,
[DATAAREA] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-885798727_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-885798727_-1273337705] UNIQUE NONCLUSTERED 
(
[DATAAREA] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_COMPANYINFO_DATAAREA]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[COMPANYINFO] ADD  CONSTRAINT [DF_COMPANYINFO_DATAAREA]  DEFAULT ('') FOR [DATAAREA]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[COMPANYINFO] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[CURRENCY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[CURRENCY](
[RECID] [bigint] NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[CURRENCYCODEISO] [nvarchar](3) NOT NULL,
[ROUNDOFFPRICE] [numeric](32, 16) NOT NULL,
[ROUNDOFFPURCH] [numeric](32, 16) NOT NULL,
[ROUNDOFFSALES] [numeric](32, 16) NOT NULL,
[ROUNDOFFTYPEPRICE] [int] NOT NULL,
[ROUNDOFFTYPEPURCH] [int] NOT NULL,
[ROUNDOFFTYPESALES] [int] NOT NULL,
[SYMBOL] [nvarchar](5) NOT NULL,
[TXT] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1650711867_1955152843] PRIMARY KEY CLUSTERED 
(
[CURRENCYCODE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_CURRENCYCODEISO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_CURRENCYCODEISO]  DEFAULT ('') FOR [CURRENCYCODEISO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_ROUNDOFFPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_ROUNDOFFPRICE]  DEFAULT ((0)) FOR [ROUNDOFFPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_ROUNDOFFPURCH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_ROUNDOFFPURCH]  DEFAULT ((0)) FOR [ROUNDOFFPURCH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_ROUNDOFFSALES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_ROUNDOFFSALES]  DEFAULT ((0)) FOR [ROUNDOFFSALES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_ROUNDOFFTYPEPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_ROUNDOFFTYPEPRICE]  DEFAULT ((0)) FOR [ROUNDOFFTYPEPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_ROUNDOFFTYPEPURCH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_ROUNDOFFTYPEPURCH]  DEFAULT ((0)) FOR [ROUNDOFFTYPEPURCH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_ROUNDOFFTYPESALES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_ROUNDOFFTYPESALES]  DEFAULT ((0)) FOR [ROUNDOFFTYPESALES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_SYMBOL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_SYMBOL]  DEFAULT ('') FOR [SYMBOL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CURRENCY_TXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CURRENCY] ADD  CONSTRAINT [DF_CURRENCY_TXT]  DEFAULT ('') FOR [TXT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[CURRENCY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[CUSTGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[CUSTGROUP](
[RECID] [bigint] NOT NULL,
[CUSTGROUP] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1620308668_1086213528] PRIMARY KEY CLUSTERED 
(
[CUSTGROUP] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTGROUP_CUSTGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTGROUP] ADD  CONSTRAINT [DF_CUSTGROUP_CUSTGROUP]  DEFAULT ('') FOR [CUSTGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTGROUP_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTGROUP] ADD  CONSTRAINT [DF_CUSTGROUP_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[CUSTGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[CUSTPACKINGSLIPJOUR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[CUSTPACKINGSLIPJOUR](
[RECID] [bigint] NOT NULL,
[PACKINGSLIPID] [nvarchar](20) NOT NULL,
[SALESID] [nvarchar](20) NOT NULL,
[SHIPCARRIERID] [nvarchar](10) NOT NULL,
[SOURCEDOCUMENTHEADER] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_868055170_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_868055170_1531416702] UNIQUE NONCLUSTERED 
(
[SOURCEDOCUMENTHEADER] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPJOUR_PACKINGSLIPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPJOUR] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPJOUR_PACKINGSLIPID]  DEFAULT ('') FOR [PACKINGSLIPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPJOUR_SALESID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPJOUR] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPJOUR_SALESID]  DEFAULT ('') FOR [SALESID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPJOUR_SHIPCARRIERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPJOUR] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPJOUR_SHIPCARRIERID]  DEFAULT ('') FOR [SHIPCARRIERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPJOUR_SOURCEDOCUMENTHEADER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPJOUR] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPJOUR_SOURCEDOCUMENTHEADER]  DEFAULT ((0)) FOR [SOURCEDOCUMENTHEADER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPJOUR_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPJOUR] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPJOUR_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[CUSTPACKINGSLIPJOUR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[CUSTPACKINGSLIPTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[CUSTPACKINGSLIPTRANS](
[RECID] [bigint] NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[ORDERED] [numeric](32, 16) NOT NULL,
[PACKINGSLIPID] [nvarchar](20) NOT NULL,
[QTY] [numeric](32, 16) NOT NULL,
[REMAIN] [numeric](32, 16) NOT NULL,
[SALESID] [nvarchar](20) NOT NULL,
[SOURCEDOCUMENTLINE] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_535734996_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_535734996_527453709] UNIQUE NONCLUSTERED 
(
[SOURCEDOCUMENTLINE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_ORDERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_ORDERED]  DEFAULT ((0)) FOR [ORDERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_PACKINGSLIPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_PACKINGSLIPID]  DEFAULT ('') FOR [PACKINGSLIPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_REMAIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_REMAIN]  DEFAULT ((0)) FOR [REMAIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_SALESID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_SALESID]  DEFAULT ('') FOR [SALESID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_SOURCEDOCUMENTLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_SOURCEDOCUMENTLINE]  DEFAULT ((0)) FOR [SOURCEDOCUMENTLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTPACKINGSLIPTRANS_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTPACKINGSLIPTRANS] ADD  CONSTRAINT [DF_CUSTPACKINGSLIPTRANS_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[CUSTPACKINGSLIPTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[CUSTTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[CUSTTABLE](
[RECID] [bigint] NOT NULL,
[ACCOUNTNUM] [nvarchar](20) NOT NULL,
[ACCOUNTSTATEMENT] [int] NOT NULL,
[BANKACCOUNT] [nvarchar](10) NOT NULL,
[BANKCENTRALBANKPURPOSECODE] [nvarchar](10) NOT NULL,
[BANKCENTRALBANKPURPOSETEXT] [nvarchar](140) NOT NULL,
[BLOCKED] [int] NOT NULL,
[CASHDISC] [nvarchar](10) NOT NULL,
[CLEARINGPERIOD] [nvarchar](10) NOT NULL,
[CNPJCPFNUM_BR] [nvarchar](20) NOT NULL,
[COMMISSIONGROUP] [nvarchar](10) NOT NULL,
[CONTACTPERSONID] [nvarchar](20) NOT NULL,
[CREDITMAX] [numeric](32, 16) NOT NULL,
[CREDITRATING] [nvarchar](10) NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[CUSTGROUP] [nvarchar](10) NOT NULL,
[CUSTITEMGROUPID] [nvarchar](10) NOT NULL,
[DESTINATIONCODEID] [nvarchar](10) NOT NULL,
[DLVMODE] [nvarchar](10) NOT NULL,
[DLVTERM] [nvarchar](10) NOT NULL,
[ENDDISC] [nvarchar](10) NOT NULL,
[FORECASTDMPINCLUDE] [int] NOT NULL,
[FREIGHTZONE] [nvarchar](10) NOT NULL,
[IDENTIFICATIONNUMBER] [nvarchar](50) NOT NULL,
[IENUM_BR] [nvarchar](20) NOT NULL,
[INCLTAX] [int] NOT NULL,
[INVENTLOCATION] [nvarchar](10) NOT NULL,
[INVENTSITEID] [nvarchar](10) NOT NULL,
[INVOICEACCOUNT] [nvarchar](20) NOT NULL,
[INVOICEADDRESS] [int] NOT NULL,
[LINEDISC] [nvarchar](10) NOT NULL,
[LINEOFBUSINESSID] [nvarchar](10) NOT NULL,
[MANDATORYCREDITLIMIT] [int] NOT NULL,
[MARKUPGROUP] [nvarchar](10) NOT NULL,
[MULTILINEDISC] [nvarchar](10) NOT NULL,
[NUMBERSEQUENCEGROUP] [nvarchar](10) NOT NULL,
[ONETIMECUSTOMER] [int] NOT NULL,
[ORGID] [nvarchar](10) NOT NULL,
[OURACCOUNTNUM] [nvarchar](20) NOT NULL,
[PACKMATERIALFEELICENSENUM] [nvarchar](20) NOT NULL,
[PARTY] [bigint] NOT NULL,
[PAYMDAYID] [nvarchar](10) NOT NULL,
[PAYMMODE] [nvarchar](10) NOT NULL,
[PAYMSPEC] [nvarchar](10) NOT NULL,
[PAYMTERMID] [nvarchar](10) NOT NULL,
[PBACUSTGROUPID] [nvarchar](10) NOT NULL,
[PRICEGROUP] [nvarchar](10) NOT NULL,
[SALESGROUP] [nvarchar](10) NOT NULL,
[SALESPOOLID] [nvarchar](10) NOT NULL,
[STATISTICSGROUP] [nvarchar](10) NOT NULL,
[SUFRAMA_BR] [int] NOT NULL,
[SUFRAMANUMBER_BR] [nvarchar](10) NOT NULL,
[SUPPITEMGROUPID] [nvarchar](10) NOT NULL,
[TAXGROUP] [nvarchar](10) NOT NULL,
[TAXLICENSENUM] [nvarchar](20) NOT NULL,
[USEPURCHREQUEST] [int] NOT NULL,
[VATNUM] [nvarchar](20) NOT NULL,
[VENDACCOUNT] [nvarchar](20) NOT NULL,
[WEBSALESORDERDISPLAY] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_880715539_-2094443312] PRIMARY KEY CLUSTERED 
(
[ACCOUNTNUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_880715539_237279918] UNIQUE NONCLUSTERED 
(
[PARTY] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_ACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_ACCOUNTNUM]  DEFAULT ('') FOR [ACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_ACCOUNTSTATEMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_ACCOUNTSTATEMENT]  DEFAULT ((0)) FOR [ACCOUNTSTATEMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_BANKACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_BANKACCOUNT]  DEFAULT ('') FOR [BANKACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_BANKCENTRALBANKPURPOSECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_BANKCENTRALBANKPURPOSECODE]  DEFAULT ('') FOR [BANKCENTRALBANKPURPOSECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_BANKCENTRALBANKPURPOSETEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_BANKCENTRALBANKPURPOSETEXT]  DEFAULT ('') FOR [BANKCENTRALBANKPURPOSETEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_BLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_BLOCKED]  DEFAULT ((0)) FOR [BLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CASHDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CASHDISC]  DEFAULT ('') FOR [CASHDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CLEARINGPERIOD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CLEARINGPERIOD]  DEFAULT ('') FOR [CLEARINGPERIOD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CNPJCPFNUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CNPJCPFNUM_BR]  DEFAULT ('') FOR [CNPJCPFNUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_COMMISSIONGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_COMMISSIONGROUP]  DEFAULT ('') FOR [COMMISSIONGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CONTACTPERSONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CONTACTPERSONID]  DEFAULT ('') FOR [CONTACTPERSONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CREDITMAX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CREDITMAX]  DEFAULT ((0)) FOR [CREDITMAX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CREDITRATING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CREDITRATING]  DEFAULT ('') FOR [CREDITRATING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CUSTGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CUSTGROUP]  DEFAULT ('') FOR [CUSTGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CUSTITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CUSTITEMGROUPID]  DEFAULT ('') FOR [CUSTITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_DESTINATIONCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_DESTINATIONCODEID]  DEFAULT ('') FOR [DESTINATIONCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_DLVMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_DLVMODE]  DEFAULT ('') FOR [DLVMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_DLVTERM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_DLVTERM]  DEFAULT ('') FOR [DLVTERM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_ENDDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_ENDDISC]  DEFAULT ('') FOR [ENDDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_FORECASTDMPINCLUDE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_FORECASTDMPINCLUDE]  DEFAULT ((0)) FOR [FORECASTDMPINCLUDE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_FREIGHTZONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_FREIGHTZONE]  DEFAULT ('') FOR [FREIGHTZONE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_IDENTIFICATIONNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_IDENTIFICATIONNUMBER]  DEFAULT ('') FOR [IDENTIFICATIONNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_IENUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_IENUM_BR]  DEFAULT ('') FOR [IENUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_INCLTAX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_INCLTAX]  DEFAULT ((0)) FOR [INCLTAX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_INVENTLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_INVENTLOCATION]  DEFAULT ('') FOR [INVENTLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_INVENTSITEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_INVENTSITEID]  DEFAULT ('') FOR [INVENTSITEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_INVOICEACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_INVOICEACCOUNT]  DEFAULT ('') FOR [INVOICEACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_INVOICEADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_INVOICEADDRESS]  DEFAULT ((0)) FOR [INVOICEADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_LINEDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_LINEDISC]  DEFAULT ('') FOR [LINEDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_LINEOFBUSINESSID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_LINEOFBUSINESSID]  DEFAULT ('') FOR [LINEOFBUSINESSID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_MANDATORYCREDITLIMIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_MANDATORYCREDITLIMIT]  DEFAULT ((0)) FOR [MANDATORYCREDITLIMIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_MARKUPGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_MARKUPGROUP]  DEFAULT ('') FOR [MARKUPGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_MULTILINEDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_MULTILINEDISC]  DEFAULT ('') FOR [MULTILINEDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_NUMBERSEQUENCEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_NUMBERSEQUENCEGROUP]  DEFAULT ('') FOR [NUMBERSEQUENCEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_ONETIMECUSTOMER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_ONETIMECUSTOMER]  DEFAULT ((0)) FOR [ONETIMECUSTOMER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_ORGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_ORGID]  DEFAULT ('') FOR [ORGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_OURACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_OURACCOUNTNUM]  DEFAULT ('') FOR [OURACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PACKMATERIALFEELICENSENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PACKMATERIALFEELICENSENUM]  DEFAULT ('') FOR [PACKMATERIALFEELICENSENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PARTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PARTY]  DEFAULT ((0)) FOR [PARTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PAYMDAYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PAYMDAYID]  DEFAULT ('') FOR [PAYMDAYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PAYMMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PAYMMODE]  DEFAULT ('') FOR [PAYMMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PAYMSPEC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PAYMSPEC]  DEFAULT ('') FOR [PAYMSPEC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PAYMTERMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PAYMTERMID]  DEFAULT ('') FOR [PAYMTERMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PBACUSTGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PBACUSTGROUPID]  DEFAULT ('') FOR [PBACUSTGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_PRICEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_PRICEGROUP]  DEFAULT ('') FOR [PRICEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_SALESGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_SALESGROUP]  DEFAULT ('') FOR [SALESGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_SALESPOOLID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_SALESPOOLID]  DEFAULT ('') FOR [SALESPOOLID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_STATISTICSGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_STATISTICSGROUP]  DEFAULT ('') FOR [STATISTICSGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_SUFRAMA_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_SUFRAMA_BR]  DEFAULT ((0)) FOR [SUFRAMA_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_SUFRAMANUMBER_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_SUFRAMANUMBER_BR]  DEFAULT ('') FOR [SUFRAMANUMBER_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_SUPPITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_SUPPITEMGROUPID]  DEFAULT ('') FOR [SUPPITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_TAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_TAXGROUP]  DEFAULT ('') FOR [TAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_TAXLICENSENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_TAXLICENSENUM]  DEFAULT ('') FOR [TAXLICENSENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_USEPURCHREQUEST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_USEPURCHREQUEST]  DEFAULT ((0)) FOR [USEPURCHREQUEST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_VATNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_VATNUM]  DEFAULT ('') FOR [VATNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_VENDACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_VENDACCOUNT]  DEFAULT ('') FOR [VENDACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_WEBSALESORDERDISPLAY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_WEBSALESORDERDISPLAY]  DEFAULT ((0)) FOR [WEBSALESORDERDISPLAY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_CUSTTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[CUSTTABLE] ADD  CONSTRAINT [DF_CUSTTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[CUSTTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DIRADDRESSBOOK]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DIRADDRESSBOOK](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[NAME] [nvarchar](10) NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2048506466_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_2048506466_910918470] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRADDRESSBOOK_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRADDRESSBOOK] ADD  CONSTRAINT [DF_DIRADDRESSBOOK_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRADDRESSBOOK_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRADDRESSBOOK] ADD  CONSTRAINT [DF_DIRADDRESSBOOK_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRADDRESSBOOK_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRADDRESSBOOK] ADD  CONSTRAINT [DF_DIRADDRESSBOOK_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRADDRESSBOOK_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRADDRESSBOOK] ADD  CONSTRAINT [DF_DIRADDRESSBOOK_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DIRADDRESSBOOK] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DIRADDRESSBOOKPARTY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DIRADDRESSBOOKPARTY](
[RECID] [bigint] NOT NULL,
[ADDRESSBOOK] [bigint] NOT NULL,
[PARTY] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_996533606_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_996533606_589292146] UNIQUE NONCLUSTERED 
(
[PARTY] ASC,
[ADDRESSBOOK] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRADDRESSBOOKPARTY_ADDRESSBOOK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRADDRESSBOOKPARTY] ADD  CONSTRAINT [DF_DIRADDRESSBOOKPARTY_ADDRESSBOOK]  DEFAULT ((0)) FOR [ADDRESSBOOK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRADDRESSBOOKPARTY_PARTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRADDRESSBOOKPARTY] ADD  CONSTRAINT [DF_DIRADDRESSBOOKPARTY_PARTY]  DEFAULT ((0)) FOR [PARTY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DIRADDRESSBOOKPARTY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DIRPARTYLOCATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DIRPARTYLOCATION](
[RECID] [bigint] NOT NULL,
[ATTENTIONTOADDRESSLINE] [nvarchar](255) NOT NULL,
[ISLOCATIONOWNER] [int] NOT NULL,
[ISPOSTALADDRESS] [int] NOT NULL,
[ISPRIMARY] [int] NOT NULL,
[ISPRIVATE] [int] NOT NULL,
[LOCATION] [bigint] NOT NULL,
[PARTY] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1696019432_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1696019432_-1627387636] UNIQUE NONCLUSTERED 
(
[PARTY] ASC,
[LOCATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_ATTENTIONTOADDRESSLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_ATTENTIONTOADDRESSLINE]  DEFAULT ('') FOR [ATTENTIONTOADDRESSLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_ISLOCATIONOWNER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_ISLOCATIONOWNER]  DEFAULT ((0)) FOR [ISLOCATIONOWNER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_ISPOSTALADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_ISPOSTALADDRESS]  DEFAULT ((0)) FOR [ISPOSTALADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_ISPRIMARY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_ISPRIMARY]  DEFAULT ((0)) FOR [ISPRIMARY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_ISPRIVATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_ISPRIVATE]  DEFAULT ((0)) FOR [ISPRIVATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_LOCATION]  DEFAULT ((0)) FOR [LOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATION_PARTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATION] ADD  CONSTRAINT [DF_DIRPARTYLOCATION_PARTY]  DEFAULT ((0)) FOR [PARTY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DIRPARTYLOCATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DIRPARTYLOCATIONROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DIRPARTYLOCATIONROLE](
[RECID] [bigint] NOT NULL,
[LOCATIONROLE] [bigint] NOT NULL,
[PARTYLOCATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_586983440_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_586983440_-1706136147] UNIQUE NONCLUSTERED 
(
[PARTYLOCATION] ASC,
[LOCATIONROLE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATIONROLE_LOCATIONROLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATIONROLE] ADD  CONSTRAINT [DF_DIRPARTYLOCATIONROLE_LOCATIONROLE]  DEFAULT ((0)) FOR [LOCATIONROLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYLOCATIONROLE_PARTYLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYLOCATIONROLE] ADD  CONSTRAINT [DF_DIRPARTYLOCATIONROLE_PARTYLOCATION]  DEFAULT ((0)) FOR [PARTYLOCATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DIRPARTYLOCATIONROLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DIRPARTYTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DIRPARTYTABLE](
[RECID] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[KNOWNAS] [nvarchar](100) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[NAME] [nvarchar](100) NOT NULL,
[NAMEALIAS] [nvarchar](20) NOT NULL,
[PARTYNUMBER] [nvarchar](40) NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-747565321_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-747565321_315771746] UNIQUE NONCLUSTERED 
(
[PARTYNUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_KNOWNAS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_KNOWNAS]  DEFAULT ('') FOR [KNOWNAS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_NAMEALIAS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_NAMEALIAS]  DEFAULT ('') FOR [NAMEALIAS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_PARTYNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_PARTYNUMBER]  DEFAULT ('') FOR [PARTYNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPARTYTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPARTYTABLE] ADD  CONSTRAINT [DF_DIRPARTYTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DIRPARTYTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DIRPERSONNAME]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DIRPERSONNAME](
[RECID] [bigint] NOT NULL,
[FIRSTNAME] [nvarchar](25) NOT NULL,
[LASTNAME] [nvarchar](25) NOT NULL,
[MIDDLENAME] [nvarchar](25) NOT NULL,
[PERSON] [bigint] NOT NULL,
[VALIDFROM] [datetime] NOT NULL,
[VALIDFROMTZID] [int] NOT NULL,
[VALIDTO] [datetime] NOT NULL,
[VALIDTOTZID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_600258457_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_600258457_-1645802954] UNIQUE NONCLUSTERED 
(
[PERSON] ASC,
[VALIDFROM] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_FIRSTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_FIRSTNAME]  DEFAULT ('') FOR [FIRSTNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_LASTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_LASTNAME]  DEFAULT ('') FOR [LASTNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_MIDDLENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_MIDDLENAME]  DEFAULT ('') FOR [MIDDLENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_PERSON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_PERSON]  DEFAULT ((0)) FOR [PERSON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_VALIDFROM]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_VALIDFROMTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_VALIDFROMTZID]  DEFAULT ((37001)) FOR [VALIDFROMTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_VALIDTO]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DIRPERSONNAME_VALIDTOTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DIRPERSONNAME] ADD  CONSTRAINT [DF_DIRPERSONNAME_VALIDTOTZID]  DEFAULT ((37001)) FOR [VALIDTOTZID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DIRPERSONNAME] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[DLVMODE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[DLVMODE](
[RECID] [bigint] NOT NULL,
[CODE] [nvarchar](10) NOT NULL,
[MARKUPGROUP] [nvarchar](10) NOT NULL,
[SHIPCARRIERACCOUNTCODE] [nvarchar](20) NOT NULL,
[SHIPCARRIERDLVTYPE] [int] NOT NULL,
[SHIPCARRIERID] [nvarchar](10) NOT NULL,
[SHIPCARRIERNAME] [nvarchar](20) NOT NULL,
[TXT] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1052277315_776425418] PRIMARY KEY CLUSTERED 
(
[CODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_CODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_CODE]  DEFAULT ('') FOR [CODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_MARKUPGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_MARKUPGROUP]  DEFAULT ('') FOR [MARKUPGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_SHIPCARRIERACCOUNTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_SHIPCARRIERACCOUNTCODE]  DEFAULT ('') FOR [SHIPCARRIERACCOUNTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_SHIPCARRIERDLVTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_SHIPCARRIERDLVTYPE]  DEFAULT ((0)) FOR [SHIPCARRIERDLVTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_SHIPCARRIERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_SHIPCARRIERID]  DEFAULT ('') FOR [SHIPCARRIERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_SHIPCARRIERNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_SHIPCARRIERNAME]  DEFAULT ('') FOR [SHIPCARRIERNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_DLVMODE_TXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[DLVMODE] ADD  CONSTRAINT [DF_DLVMODE_TXT]  DEFAULT ('') FOR [TXT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[DLVMODE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESATTRIBUTE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESATTRIBUTE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTEMODIFIER] [int] NOT NULL,
[ATTRIBUTETYPE] [bigint] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1988291431_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTE_ATTRIBUTEMODIFIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTE] ADD  CONSTRAINT [DF_ECORESATTRIBUTE_ATTRIBUTEMODIFIER]  DEFAULT ((0)) FOR [ATTRIBUTEMODIFIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTE_ATTRIBUTETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTE] ADD  CONSTRAINT [DF_ECORESATTRIBUTE_ATTRIBUTETYPE]  DEFAULT ((0)) FOR [ATTRIBUTETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTE] ADD  CONSTRAINT [DF_ECORESATTRIBUTE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESATTRIBUTE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESATTRIBUTEDEFAULTVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESATTRIBUTEDEFAULTVALUE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[VALUE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-306725327_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEDEFAULTVALUE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEDEFAULTVALUE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEDEFAULTVALUE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEDEFAULTVALUE_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEDEFAULTVALUE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEDEFAULTVALUE_VALUE]  DEFAULT ((0)) FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESATTRIBUTEDEFAULTVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESATTRIBUTEGROUPATTRIBUTE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESATTRIBUTEGROUPATTRIBUTE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[ATTRIBUTEGROUP] [bigint] NOT NULL,
[DEFAULTVALUE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_461708616_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_461708616_-255559742] UNIQUE NONCLUSTERED 
(
[ATTRIBUTEGROUP] ASC,
[ATTRIBUTE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEGROUPATTRIBUTE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEGROUPATTRIBUTE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEGROUPATTRIBUTE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEGROUPATTRIBUTE_ATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEGROUPATTRIBUTE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEGROUPATTRIBUTE_ATTRIBUTEGROUP]  DEFAULT ((0)) FOR [ATTRIBUTEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEGROUPATTRIBUTE_DEFAULTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEGROUPATTRIBUTE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEGROUPATTRIBUTE_DEFAULTVALUE]  DEFAULT ((0)) FOR [DEFAULTVALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESATTRIBUTEGROUPATTRIBUTE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESATTRIBUTETRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESATTRIBUTETRANSLATION](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[FRIENDLYNAME] [nvarchar](120) NOT NULL,
[HELPTEXT] [nvarchar](255) NOT NULL,
[LANGUAGE] [nvarchar](7) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1990869088_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1990869088_2081875952] UNIQUE NONCLUSTERED 
(
[ATTRIBUTE] ASC,
[LANGUAGE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETRANSLATION_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETRANSLATION] ADD  CONSTRAINT [DF_ECORESATTRIBUTETRANSLATION_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETRANSLATION] ADD  CONSTRAINT [DF_ECORESATTRIBUTETRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETRANSLATION_FRIENDLYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETRANSLATION] ADD  CONSTRAINT [DF_ECORESATTRIBUTETRANSLATION_FRIENDLYNAME]  DEFAULT ('') FOR [FRIENDLYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETRANSLATION_HELPTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETRANSLATION] ADD  CONSTRAINT [DF_ECORESATTRIBUTETRANSLATION_HELPTEXT]  DEFAULT ('') FOR [HELPTEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETRANSLATION_LANGUAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETRANSLATION] ADD  CONSTRAINT [DF_ECORESATTRIBUTETRANSLATION_LANGUAGE]  DEFAULT ('') FOR [LANGUAGE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESATTRIBUTETRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESATTRIBUTETYPE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESATTRIBUTETYPE](
[RECID] [bigint] NOT NULL,
[DATATYPE] [int] NOT NULL,
[ISENUMERATION] [int] NOT NULL,
[ISHIDDEN] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1716185735_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1716185735_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETYPE_DATATYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETYPE] ADD  CONSTRAINT [DF_ECORESATTRIBUTETYPE_DATATYPE]  DEFAULT ((0)) FOR [DATATYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETYPE_ISENUMERATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETYPE] ADD  CONSTRAINT [DF_ECORESATTRIBUTETYPE_ISENUMERATION]  DEFAULT ((0)) FOR [ISENUMERATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETYPE_ISHIDDEN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETYPE] ADD  CONSTRAINT [DF_ECORESATTRIBUTETYPE_ISHIDDEN]  DEFAULT ((0)) FOR [ISHIDDEN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTETYPE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTETYPE] ADD  CONSTRAINT [DF_ECORESATTRIBUTETYPE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESATTRIBUTETYPE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESATTRIBUTEVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESATTRIBUTEVALUE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[INSTANCEVALUE] [bigint] NOT NULL,
[VALUE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2006788166_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEVALUE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEVALUE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEVALUE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEVALUE_INSTANCEVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEVALUE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEVALUE_INSTANCEVALUE]  DEFAULT ((0)) FOR [INSTANCEVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESATTRIBUTEVALUE_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESATTRIBUTEVALUE] ADD  CONSTRAINT [DF_ECORESATTRIBUTEVALUE_VALUE]  DEFAULT ((0)) FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESATTRIBUTEVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESBOOLEANVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESBOOLEANVALUE](
[RECID] [bigint] NOT NULL,
[BOOLEANVALUE] [int] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1443038458_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESBOOLEANVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCATEGORY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCATEGORY](
[RECID] [bigint] NOT NULL,
[CATEGORYHIERARCHY] [bigint] NOT NULL,
[CHANGESTATUS] [int] NOT NULL,
[CODE] [nvarchar](20) NOT NULL,
[DEFAULTPROJECTGLOBALCATEGORY] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[ISACTIVE] [int] NOT NULL,
[ISCATEGORYATTRIBUTESINHERITED] [int] NOT NULL,
[ISTANGIBLE] [int] NOT NULL,
[LEVEL] [bigint] NOT NULL,
[NAME] [nvarchar](254) NOT NULL,
[NESTEDSETLEFT] [bigint] NOT NULL,
[NESTEDSETRIGHT] [bigint] NOT NULL,
[PARENTCATEGORY] [bigint] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1608894095_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1608894095_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC,
[CATEGORYHIERARCHY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_CATEGORYHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_CATEGORYHIERARCHY]  DEFAULT ((0)) FOR [CATEGORYHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_CHANGESTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_CHANGESTATUS]  DEFAULT ((0)) FOR [CHANGESTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_CODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_CODE]  DEFAULT ('') FOR [CODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_DEFAULTPROJECTGLOBALCATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_DEFAULTPROJECTGLOBALCATEGORY]  DEFAULT ((0)) FOR [DEFAULTPROJECTGLOBALCATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_ISACTIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_ISACTIVE]  DEFAULT ((0)) FOR [ISACTIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_ISCATEGORYATTRIBUTESINHERITED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_ISCATEGORYATTRIBUTESINHERITED]  DEFAULT ((0)) FOR [ISCATEGORYATTRIBUTESINHERITED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_ISTANGIBLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_ISTANGIBLE]  DEFAULT ((0)) FOR [ISTANGIBLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_LEVEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_LEVEL]  DEFAULT ((0)) FOR [LEVEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_NESTEDSETLEFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_NESTEDSETLEFT]  DEFAULT ((0)) FOR [NESTEDSETLEFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_NESTEDSETRIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_NESTEDSETRIGHT]  DEFAULT ((0)) FOR [NESTEDSETRIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_PARENTCATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_PARENTCATEGORY]  DEFAULT ((0)) FOR [PARENTCATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORY_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORY] ADD  CONSTRAINT [DF_ECORESCATEGORY_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCATEGORY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCATEGORYATTRIBUTEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCATEGORYATTRIBUTEGROUP](
[RECID] [bigint] NOT NULL,
[ATTRIBUTEGROUP] [bigint] NOT NULL,
[ATTRIBUTEGROUPTYPE] [int] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[MODIFIER] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1480101260_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1480101260_-1614480561] UNIQUE NONCLUSTERED 
(
[ATTRIBUTEGROUP] ASC,
[CATEGORY] ASC,
[MODIFIER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTEGROUP_ATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTEGROUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTEGROUP_ATTRIBUTEGROUP]  DEFAULT ((0)) FOR [ATTRIBUTEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTEGROUP_ATTRIBUTEGROUPTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTEGROUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTEGROUP_ATTRIBUTEGROUPTYPE]  DEFAULT ((0)) FOR [ATTRIBUTEGROUPTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTEGROUP_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTEGROUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTEGROUP_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTEGROUP_MODIFIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTEGROUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTEGROUP_MODIFIER]  DEFAULT ((0)) FOR [MODIFIER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCATEGORYATTRIBUTEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCATEGORYATTRIBUTELOOKUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCATEGORYATTRIBUTELOOKUP](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[ATTRIBUTEGROUPATTRIBUTE] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[CATEGORYATTRIBUTE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1521133457_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1521133457_-2122509987] UNIQUE NONCLUSTERED 
(
[CATEGORY] ASC,
[ATTRIBUTE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTELOOKUP_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTELOOKUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTELOOKUP_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTELOOKUP_ATTRIBUTEGROUPATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTELOOKUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTELOOKUP_ATTRIBUTEGROUPATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTEGROUPATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTELOOKUP_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTELOOKUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTELOOKUP_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYATTRIBUTELOOKUP_CATEGORYATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYATTRIBUTELOOKUP] ADD  CONSTRAINT [DF_ECORESCATEGORYATTRIBUTELOOKUP_CATEGORYATTRIBUTE]  DEFAULT ((0)) FOR [CATEGORYATTRIBUTE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCATEGORYATTRIBUTELOOKUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCATEGORYHIERARCHY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCATEGORYHIERARCHY](
[RECID] [bigint] NOT NULL,
[HIERARCHYMODIFIER] [int] NOT NULL,
[NAME] [nvarchar](128) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-979199422_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-979199422_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYHIERARCHY_HIERARCHYMODIFIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYHIERARCHY] ADD  CONSTRAINT [DF_ECORESCATEGORYHIERARCHY_HIERARCHYMODIFIER]  DEFAULT ((0)) FOR [HIERARCHYMODIFIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYHIERARCHY_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYHIERARCHY] ADD  CONSTRAINT [DF_ECORESCATEGORYHIERARCHY_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCATEGORYHIERARCHY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCATEGORYHIERARCHYROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCATEGORYHIERARCHYROLE](
[RECID] [bigint] NOT NULL,
[CATEGORYHIERARCHY] [bigint] NOT NULL,
[NAMEDCATEGORYHIERARCHYROLE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_686403814_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_686403814_-1937137019] UNIQUE NONCLUSTERED 
(
[NAMEDCATEGORYHIERARCHYROLE] ASC,
[CATEGORYHIERARCHY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYHIERARCHYROLE_CATEGORYHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYHIERARCHYROLE] ADD  CONSTRAINT [DF_ECORESCATEGORYHIERARCHYROLE_CATEGORYHIERARCHY]  DEFAULT ((0)) FOR [CATEGORYHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYHIERARCHYROLE_NAMEDCATEGORYHIERARCHYROLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYHIERARCHYROLE] ADD  CONSTRAINT [DF_ECORESCATEGORYHIERARCHYROLE_NAMEDCATEGORYHIERARCHYROLE]  DEFAULT ((0)) FOR [NAMEDCATEGORYHIERARCHYROLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCATEGORYHIERARCHYROLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCATEGORYTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCATEGORYTRANSLATION](
[RECID] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](1000) NOT NULL,
[FRIENDLYNAME] [nvarchar](254) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[SEARCHTEXT] [nvarchar](254) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1435627490_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1435627490_-888948581] UNIQUE NONCLUSTERED 
(
[CATEGORY] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYTRANSLATION_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_ECORESCATEGORYTRANSLATION_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_ECORESCATEGORYTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYTRANSLATION_FRIENDLYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_ECORESCATEGORYTRANSLATION_FRIENDLYNAME]  DEFAULT ('') FOR [FRIENDLYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_ECORESCATEGORYTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCATEGORYTRANSLATION_SEARCHTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_ECORESCATEGORYTRANSLATION_SEARCHTEXT]  DEFAULT ('') FOR [SEARCHTEXT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCATEGORYTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCOLOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCOLOR](
[RECID] [bigint] NOT NULL,
[NAME] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1935030618_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1935030618_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCOLOR_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCOLOR] ADD  CONSTRAINT [DF_ECORESCOLOR_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCOLOR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCONFIGURATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCONFIGURATION](
[RECID] [bigint] NOT NULL,
[NAME] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1043434429_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1043434429_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCONFIGURATION_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCONFIGURATION] ADD  CONSTRAINT [DF_ECORESCONFIGURATION_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCONFIGURATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESCURRENCYVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESCURRENCYVALUE](
[RECID] [bigint] NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[CURRENCYVALUE] [numeric](32, 16) NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1964246449_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESCURRENCYVALUE_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESCURRENCYVALUE] ADD  CONSTRAINT [DF_ECORESCURRENCYVALUE_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESCURRENCYVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESDATETIMEVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESDATETIMEVALUE](
[RECID] [bigint] NOT NULL,
[DATETIMEVALUE] [datetime] NULL,
[DATETIMEVALUETZID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-809579165_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESDATETIMEVALUE_DATETIMEVALUETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESDATETIMEVALUE] ADD  CONSTRAINT [DF_ECORESDATETIMEVALUE_DATETIMEVALUETZID]  DEFAULT ((37001)) FOR [DATETIMEVALUETZID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESDATETIMEVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESDISTINCTPRODUCTVARIANT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESDISTINCTPRODUCTVARIANT](
[RECID] [bigint] NOT NULL,
[PRODUCTMASTER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1270744131_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESDISTINCTPRODUCTVARIANT_PRODUCTMASTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESDISTINCTPRODUCTVARIANT] ADD  CONSTRAINT [DF_ECORESDISTINCTPRODUCTVARIANT_PRODUCTMASTER]  DEFAULT ((0)) FOR [PRODUCTMASTER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESDISTINCTPRODUCTVARIANT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESFLOATVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESFLOATVALUE](
[RECID] [bigint] NOT NULL,
[FLOATUNITOFMEASURE] [bigint] NULL,
[FLOATVALUE] [numeric](32, 16) NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_656793196_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESFLOATVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESINSTANCEVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESINSTANCEVALUE](
[RECID] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_544155415_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESINSTANCEVALUE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESINSTANCEVALUE] ADD  CONSTRAINT [DF_ECORESINSTANCEVALUE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESINSTANCEVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESINTVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESINTVALUE](
[RECID] [bigint] NOT NULL,
[INTUNITOFMEASURE] [bigint] NULL,
[INTVALUE] [int] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_351683345_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESINTVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCT](
[RECID] [bigint] NOT NULL,
[DISPLAYPRODUCTNUMBER] [nvarchar](70) NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[PRODUCTTYPE] [int] NOT NULL,
[SEARCHNAME] [nvarchar](20) NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-441108210_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-441108210_532903983] UNIQUE NONCLUSTERED 
(
[DISPLAYPRODUCTNUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCT_DISPLAYPRODUCTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCT] ADD  CONSTRAINT [DF_ECORESPRODUCT_DISPLAYPRODUCTNUMBER]  DEFAULT ('') FOR [DISPLAYPRODUCTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCT_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCT] ADD  CONSTRAINT [DF_ECORESPRODUCT_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCT_PRODUCTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCT] ADD  CONSTRAINT [DF_ECORESPRODUCT_PRODUCTTYPE]  DEFAULT ((0)) FOR [PRODUCTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCT_SEARCHNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCT] ADD  CONSTRAINT [DF_ECORESPRODUCT_SEARCHNAME]  DEFAULT ('') FOR [SEARCHNAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTCATEGORY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTCATEGORY](
[RECID] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[CATEGORYHIERARCHY] [bigint] NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_474291702_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_474291702_345072579] UNIQUE NONCLUSTERED 
(
[PRODUCT] ASC,
[CATEGORY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTCATEGORY_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTCATEGORY] ADD  CONSTRAINT [DF_ECORESPRODUCTCATEGORY_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTCATEGORY_CATEGORYHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTCATEGORY] ADD  CONSTRAINT [DF_ECORESPRODUCTCATEGORY_CATEGORYHIERARCHY]  DEFAULT ((0)) FOR [CATEGORYHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTCATEGORY_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTCATEGORY] ADD  CONSTRAINT [DF_ECORESPRODUCTCATEGORY_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTCATEGORY_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTCATEGORY] ADD  CONSTRAINT [DF_ECORESPRODUCTCATEGORY_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTCATEGORY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTIMAGE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTIMAGE](
[RECID] [bigint] NOT NULL,
[DEFAULTIMAGE] [int] NOT NULL,
[MEDIUMSIZE] [varbinary](max) NULL,
[REFRECORD] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_138521337_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTIMAGE_DEFAULTIMAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTIMAGE] ADD  CONSTRAINT [DF_ECORESPRODUCTIMAGE_DEFAULTIMAGE]  DEFAULT ((0)) FOR [DEFAULTIMAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTIMAGE_REFRECORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTIMAGE] ADD  CONSTRAINT [DF_ECORESPRODUCTIMAGE_REFRECORD]  DEFAULT ((0)) FOR [REFRECORD]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTIMAGE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTINSTANCEVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTINSTANCEVALUE](
[RECID] [bigint] NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1181257446_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1181257446_-474954108] UNIQUE NONCLUSTERED 
(
[PRODUCT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTINSTANCEVALUE_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTINSTANCEVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTINSTANCEVALUE_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTINSTANCEVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTMASTERCOLOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTMASTERCOLOR](
[RECID] [bigint] NOT NULL,
[COLOR] [bigint] NOT NULL,
[COLORPRODUCTDIMENSIONATTRIBUTE] [bigint] NOT NULL,
[COLORPRODUCTMASTER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-245487881_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-245487881_1679221303] UNIQUE NONCLUSTERED 
(
[COLORPRODUCTMASTER] ASC,
[COLORPRODUCTDIMENSIONATTRIBUTE] ASC,
[COLOR] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERCOLOR_COLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERCOLOR] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERCOLOR_COLOR]  DEFAULT ((0)) FOR [COLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERCOLOR_COLORPRODUCTDIMENSIONATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERCOLOR] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERCOLOR_COLORPRODUCTDIMENSIONATTRIBUTE]  DEFAULT ((0)) FOR [COLORPRODUCTDIMENSIONATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERCOLOR_COLORPRODUCTMASTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERCOLOR] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERCOLOR_COLORPRODUCTMASTER]  DEFAULT ((0)) FOR [COLORPRODUCTMASTER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTMASTERCOLOR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTMASTERCONFIGURATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTMASTERCONFIGURATION](
[RECID] [bigint] NOT NULL,
[CONFIGPRODUCTDIMENSIONATTRIBUTE] [bigint] NOT NULL,
[CONFIGPRODUCTMASTER] [bigint] NOT NULL,
[CONFIGURATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2132147850_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_2132147850_-1900482308] UNIQUE NONCLUSTERED 
(
[CONFIGPRODUCTMASTER] ASC,
[CONFIGPRODUCTDIMENSIONATTRIBUTE] ASC,
[CONFIGURATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERCONFIGURATION_CONFIGPRODUCTDIMENSIONATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERCONFIGURATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERCONFIGURATION_CONFIGPRODUCTDIMENSIONATTRIBUTE]  DEFAULT ((0)) FOR [CONFIGPRODUCTDIMENSIONATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERCONFIGURATION_CONFIGPRODUCTMASTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERCONFIGURATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERCONFIGURATION_CONFIGPRODUCTMASTER]  DEFAULT ((0)) FOR [CONFIGPRODUCTMASTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERCONFIGURATION_CONFIGURATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERCONFIGURATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERCONFIGURATION_CONFIGURATION]  DEFAULT ((0)) FOR [CONFIGURATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTMASTERCONFIGURATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTMASTERDIMENSIONVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTMASTERDIMENSIONVALUE](
[RECID] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[RETAILDISPLAYORDER] [numeric](32, 16) NOT NULL,
[RETAILWEIGHT] [int] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-890205203_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMENSIONVALUE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMENSIONVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMENSIONVALUE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMENSIONVALUE_RETAILDISPLAYORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMENSIONVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMENSIONVALUE_RETAILDISPLAYORDER]  DEFAULT ((0)) FOR [RETAILDISPLAYORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMENSIONVALUE_RETAILWEIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMENSIONVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMENSIONVALUE_RETAILWEIGHT]  DEFAULT ((0)) FOR [RETAILWEIGHT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTMASTERDIMENSIONVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](1000) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[PRODUCTMASTERDIMENSIONVALUE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1147335506_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1147335506_-973044609] UNIQUE NONCLUSTERED 
(
[PRODUCTMASTERDIMENSIONVALUE] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_PRODUCTMASTERDIMENSIONVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERDIMVALUETRANSLATION_PRODUCTMASTERDIMENSIONVALUE]  DEFAULT ((0)) FOR [PRODUCTMASTERDIMENSIONVALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTMASTERDIMVALUETRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTMASTERSIZE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTMASTERSIZE](
[RECID] [bigint] NOT NULL,
[SIZE] [bigint] NOT NULL,
[SIZEPRODUCTDIMENSIONATTRIBUTE] [bigint] NOT NULL,
[SIZEPRODUCTMASTER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1630785697_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1630785697_410463323] UNIQUE NONCLUSTERED 
(
[SIZEPRODUCTMASTER] ASC,
[SIZEPRODUCTDIMENSIONATTRIBUTE] ASC,
[SIZE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERSIZE_SIZE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERSIZE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERSIZE_SIZE]  DEFAULT ((0)) FOR [SIZE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERSIZE_SIZEPRODUCTDIMENSIONATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERSIZE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERSIZE_SIZEPRODUCTDIMENSIONATTRIBUTE]  DEFAULT ((0)) FOR [SIZEPRODUCTDIMENSIONATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERSIZE_SIZEPRODUCTMASTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERSIZE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERSIZE_SIZEPRODUCTMASTER]  DEFAULT ((0)) FOR [SIZEPRODUCTMASTER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTMASTERSIZE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTMASTERSTYLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTMASTERSTYLE](
[RECID] [bigint] NOT NULL,
[STYLE] [bigint] NOT NULL,
[STYLEPRODUCTDIMENSIONATTRIBUTE] [bigint] NOT NULL,
[STYLEPRODUCTMASTER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1455273879_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1455273879_-671292583] UNIQUE NONCLUSTERED 
(
[STYLEPRODUCTMASTER] ASC,
[STYLEPRODUCTDIMENSIONATTRIBUTE] ASC,
[STYLE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERSTYLE_STYLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERSTYLE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERSTYLE_STYLE]  DEFAULT ((0)) FOR [STYLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERSTYLE_STYLEPRODUCTDIMENSIONATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERSTYLE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERSTYLE_STYLEPRODUCTDIMENSIONATTRIBUTE]  DEFAULT ((0)) FOR [STYLEPRODUCTDIMENSIONATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTMASTERSTYLE_STYLEPRODUCTMASTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTMASTERSTYLE] ADD  CONSTRAINT [DF_ECORESPRODUCTMASTERSTYLE_STYLEPRODUCTMASTER]  DEFAULT ((0)) FOR [STYLEPRODUCTMASTER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTMASTERSTYLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTRELATIONTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTRELATIONTABLE](
[RECID] [bigint] NOT NULL,
[PRODUCT1] [bigint] NOT NULL,
[PRODUCT2] [bigint] NOT NULL,
[PRODUCTRELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_705077454_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_705077454_-382657853] UNIQUE NONCLUSTERED 
(
[PRODUCT1] ASC,
[PRODUCTRELATIONTYPE] ASC,
[PRODUCT2] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTRELATIONTABLE_PRODUCT1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTRELATIONTABLE] ADD  CONSTRAINT [DF_ECORESPRODUCTRELATIONTABLE_PRODUCT1]  DEFAULT ((0)) FOR [PRODUCT1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTRELATIONTABLE_PRODUCT2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTRELATIONTABLE] ADD  CONSTRAINT [DF_ECORESPRODUCTRELATIONTABLE_PRODUCT2]  DEFAULT ((0)) FOR [PRODUCT2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTRELATIONTABLE_PRODUCTRELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTRELATIONTABLE] ADD  CONSTRAINT [DF_ECORESPRODUCTRELATIONTABLE_PRODUCTRELATIONTYPE]  DEFAULT ((0)) FOR [PRODUCTRELATIONTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTRELATIONTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTRELATIONTYPE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTRELATIONTYPE](
[RECID] [bigint] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1362932938_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1362932938_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTRELATIONTYPE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTRELATIONTYPE] ADD  CONSTRAINT [DF_ECORESPRODUCTRELATIONTYPE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTRELATIONTYPE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTTRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](1000) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1618573415_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1618573415_168464721] UNIQUE NONCLUSTERED 
(
[RECID] ASC,
[PRODUCT] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1618573415_-1991811118] UNIQUE NONCLUSTERED 
(
[PRODUCT] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTTRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTTRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTTRANSLATION_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTTRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTTRANSLATION_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTTRANSLATION_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTTRANSLATION] ADD  CONSTRAINT [DF_ECORESPRODUCTTRANSLATION_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTVARIANTCOLOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTVARIANTCOLOR](
[RECID] [bigint] NOT NULL,
[COLOR] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_90086398_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTCOLOR_COLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTCOLOR] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTCOLOR_COLOR]  DEFAULT ((0)) FOR [COLOR]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTVARIANTCOLOR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTVARIANTCONFIGURATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTVARIANTCONFIGURATION](
[RECID] [bigint] NOT NULL,
[CONFIGURATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-54286215_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTCONFIGURATION_CONFIGURATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTCONFIGURATION] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTCONFIGURATION_CONFIGURATION]  DEFAULT ((0)) FOR [CONFIGURATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTVARIANTCONFIGURATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTVARIANTDIMENSIONVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTVARIANTDIMENSIONVALUE](
[RECID] [bigint] NOT NULL,
[DISTINCTPRODUCTVARIANT] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[PRODUCTDIMENSIONATTRIBUTE] [bigint] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-69226718_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-69226718_-1266844630] UNIQUE NONCLUSTERED 
(
[DISTINCTPRODUCTVARIANT] ASC,
[PRODUCTDIMENSIONATTRIBUTE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTDIMENSIONVALUE_DISTINCTPRODUCTVARIANT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTDIMENSIONVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTDIMENSIONVALUE_DISTINCTPRODUCTVARIANT]  DEFAULT ((0)) FOR [DISTINCTPRODUCTVARIANT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTDIMENSIONVALUE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTDIMENSIONVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTDIMENSIONVALUE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTDIMENSIONVALUE_PRODUCTDIMENSIONATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTDIMENSIONVALUE] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTDIMENSIONVALUE_PRODUCTDIMENSIONATTRIBUTE]  DEFAULT ((0)) FOR [PRODUCTDIMENSIONATTRIBUTE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTVARIANTDIMENSIONVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTVARIANTSIZE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTVARIANTSIZE](
[RECID] [bigint] NOT NULL,
[SIZE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_181768102_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTSIZE_SIZE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTSIZE] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTSIZE_SIZE]  DEFAULT ((0)) FOR [SIZE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTVARIANTSIZE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESPRODUCTVARIANTSTYLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESPRODUCTVARIANTSTYLE](
[RECID] [bigint] NOT NULL,
[STYLE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1931830212_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESPRODUCTVARIANTSTYLE_STYLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESPRODUCTVARIANTSTYLE] ADD  CONSTRAINT [DF_ECORESPRODUCTVARIANTSTYLE_STYLE]  DEFAULT ((0)) FOR [STYLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESPRODUCTVARIANTSTYLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESREFERENCEVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESREFERENCEVALUE](
[RECID] [bigint] NOT NULL,
[REFFIELDID] [int] NULL,
[REFRECID] [bigint] NULL,
[REFTABLEID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_509484233_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESREFERENCEVALUE_REFTABLEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESREFERENCEVALUE] ADD  CONSTRAINT [DF_ECORESREFERENCEVALUE_REFTABLEID]  DEFAULT ((0)) FOR [REFTABLEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESREFERENCEVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESSIZE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESSIZE](
[RECID] [bigint] NOT NULL,
[NAME] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_357393082_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_357393082_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESSIZE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESSIZE] ADD  CONSTRAINT [DF_ECORESSIZE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESSIZE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESSTYLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESSTYLE](
[RECID] [bigint] NOT NULL,
[NAME] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_967371264_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_967371264_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESSTYLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESSTYLE] ADD  CONSTRAINT [DF_ECORESSTYLE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESSTYLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESTEXTVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESTEXTVALUE](
[RECID] [bigint] NOT NULL,
[TEXTVALUE] [nvarchar](1999) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1324545795_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTEXTVALUE_TEXTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTEXTVALUE] ADD  CONSTRAINT [DF_ECORESTEXTVALUE_TEXTVALUE]  DEFAULT ('') FOR [TEXTVALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESTEXTVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESTEXTVALUETRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESTEXTVALUETRANSLATION](
[RECID] [bigint] NOT NULL,
[LANGUAGE] [nvarchar](7) NOT NULL,
[TEXTVALUE] [nvarchar](1999) NOT NULL,
[TEXTVALUETABLE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1489278364_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1489278364_1876204403] UNIQUE NONCLUSTERED 
(
[TEXTVALUETABLE] ASC,
[LANGUAGE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTEXTVALUETRANSLATION_LANGUAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTEXTVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESTEXTVALUETRANSLATION_LANGUAGE]  DEFAULT ('') FOR [LANGUAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTEXTVALUETRANSLATION_TEXTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTEXTVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESTEXTVALUETRANSLATION_TEXTVALUE]  DEFAULT ('') FOR [TEXTVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTEXTVALUETRANSLATION_TEXTVALUETABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTEXTVALUETRANSLATION] ADD  CONSTRAINT [DF_ECORESTEXTVALUETRANSLATION_TEXTVALUETABLE]  DEFAULT ((0)) FOR [TEXTVALUETABLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESTEXTVALUETRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP](
[RECID] [bigint] NOT NULL,
[DIMENSIONFIELDID] [int] NOT NULL,
[ISACTIVE] [int] NOT NULL,
[ISALLOWBLANKISSUEENABLED] [int] NOT NULL,
[ISSALESPROCESSACTIVATED] [int] NOT NULL,
[TRACKINGDIMENSIONGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1701906886_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1701906886_1841106920] UNIQUE NONCLUSTERED 
(
[TRACKINGDIMENSIONGROUP] ASC,
[DIMENSIONFIELDID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_DIMENSIONFIELDID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_DIMENSIONFIELDID]  DEFAULT ((0)) FOR [DIMENSIONFIELDID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_ISACTIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_ISACTIVE]  DEFAULT ((0)) FOR [ISACTIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_ISALLOWBLANKISSUEENABLED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_ISALLOWBLANKISSUEENABLED]  DEFAULT ((0)) FOR [ISALLOWBLANKISSUEENABLED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_ISSALESPROCESSACTIVATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_ISSALESPROCESSACTIVATED]  DEFAULT ((0)) FOR [ISSALESPROCESSACTIVATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_TRACKINGDIMENSIONGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPFLDSETUP_TRACKINGDIMENSIONGROUP]  DEFAULT ((0)) FOR [TRACKINGDIMENSIONGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESTRACKINGDIMENSIONGROUPFLDSETUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESTRACKINGDIMENSIONGROUPITEM]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPITEM](
[RECID] [bigint] NOT NULL,
[ITEMDATAAREAID] [nvarchar](4) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[TRACKINGDIMENSIONGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-174369730_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-174369730_1322497665] UNIQUE NONCLUSTERED 
(
[ITEMID] ASC,
[ITEMDATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPITEM_ITEMDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPITEM] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPITEM_ITEMDATAAREAID]  DEFAULT ('') FOR [ITEMDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPITEM_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPITEM] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPITEM_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPITEM_TRACKINGDIMENSIONGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPITEM] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPITEM_TRACKINGDIMENSIONGROUP]  DEFAULT ((0)) FOR [TRACKINGDIMENSIONGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESTRACKINGDIMENSIONGROUPITEM] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESTRACKINGDIMENSIONGROUPPRODUCT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPPRODUCT](
[RECID] [bigint] NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[TRACKINGDIMENSIONGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1127445604_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1127445604_1005329023] UNIQUE NONCLUSTERED 
(
[PRODUCT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPPRODUCT_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPPRODUCT] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPPRODUCT_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESTRACKINGDIMENSIONGROUPPRODUCT_TRACKINGDIMENSIONGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESTRACKINGDIMENSIONGROUPPRODUCT] ADD  CONSTRAINT [DF_ECORESTRACKINGDIMENSIONGROUPPRODUCT_TRACKINGDIMENSIONGROUP]  DEFAULT ((0)) FOR [TRACKINGDIMENSIONGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESTRACKINGDIMENSIONGROUPPRODUCT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[ECORESVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[ECORESVALUE](
[RECID] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_698346388_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_ECORESVALUE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[ECORESVALUE] ADD  CONSTRAINT [DF_ECORESVALUE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[ECORESVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[EXCEPTIONCODETABLE_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[EXCEPTIONCODETABLE_BR](
[RECID] [bigint] NOT NULL,
[APPROXTAXVALUEIMPORTED] [numeric](32, 16) NOT NULL,
[APPROXTAXVALUENATIONAL] [numeric](32, 16) NOT NULL,
[EXCEPTIONCODE] [nvarchar](10) NOT NULL,
[TAXFISCALCLASSIFICATIONID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_671712487_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_671712487_-482247933] UNIQUE NONCLUSTERED 
(
[TAXFISCALCLASSIFICATIONID] ASC,
[EXCEPTIONCODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCEPTIONCODETABLE_BR_APPROXTAXVALUEIMPORTED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCEPTIONCODETABLE_BR] ADD  CONSTRAINT [DF_EXCEPTIONCODETABLE_BR_APPROXTAXVALUEIMPORTED]  DEFAULT ((0)) FOR [APPROXTAXVALUEIMPORTED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCEPTIONCODETABLE_BR_APPROXTAXVALUENATIONAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCEPTIONCODETABLE_BR] ADD  CONSTRAINT [DF_EXCEPTIONCODETABLE_BR_APPROXTAXVALUENATIONAL]  DEFAULT ((0)) FOR [APPROXTAXVALUENATIONAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCEPTIONCODETABLE_BR_EXCEPTIONCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCEPTIONCODETABLE_BR] ADD  CONSTRAINT [DF_EXCEPTIONCODETABLE_BR_EXCEPTIONCODE]  DEFAULT ('') FOR [EXCEPTIONCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCEPTIONCODETABLE_BR_TAXFISCALCLASSIFICATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCEPTIONCODETABLE_BR] ADD  CONSTRAINT [DF_EXCEPTIONCODETABLE_BR_TAXFISCALCLASSIFICATIONID]  DEFAULT ('') FOR [TAXFISCALCLASSIFICATIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[EXCEPTIONCODETABLE_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[EXCHANGERATE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[EXCHANGERATE](
[RECID] [bigint] NOT NULL,
[EXCHANGERATE] [numeric](32, 16) NOT NULL,
[EXCHANGERATECURRENCYPAIR] [bigint] NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_555506149_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_555506149_-858666067] UNIQUE NONCLUSTERED 
(
[EXCHANGERATECURRENCYPAIR] ASC,
[VALIDFROM] ASC,
[VALIDTO] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATE_EXCHANGERATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATE] ADD  CONSTRAINT [DF_EXCHANGERATE_EXCHANGERATE]  DEFAULT ((0)) FOR [EXCHANGERATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATE_EXCHANGERATECURRENCYPAIR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATE] ADD  CONSTRAINT [DF_EXCHANGERATE_EXCHANGERATECURRENCYPAIR]  DEFAULT ((0)) FOR [EXCHANGERATECURRENCYPAIR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATE_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATE] ADD  CONSTRAINT [DF_EXCHANGERATE_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATE_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATE] ADD  CONSTRAINT [DF_EXCHANGERATE_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATE] ADD  CONSTRAINT [DF_EXCHANGERATE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[EXCHANGERATE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[EXCHANGERATECURRENCYPAIR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[EXCHANGERATECURRENCYPAIR](
[RECID] [bigint] NOT NULL,
[EXCHANGERATEDISPLAYFACTOR] [int] NOT NULL,
[EXCHANGERATETYPE] [bigint] NOT NULL,
[FROMCURRENCYCODE] [nvarchar](3) NOT NULL,
[TOCURRENCYCODE] [nvarchar](3) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1152046774_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1152046774_-946998140] UNIQUE NONCLUSTERED 
(
[FROMCURRENCYCODE] ASC,
[TOCURRENCYCODE] ASC,
[EXCHANGERATETYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATECURRENCYPAIR_EXCHANGERATEDISPLAYFACTOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATECURRENCYPAIR] ADD  CONSTRAINT [DF_EXCHANGERATECURRENCYPAIR_EXCHANGERATEDISPLAYFACTOR]  DEFAULT ((0)) FOR [EXCHANGERATEDISPLAYFACTOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATECURRENCYPAIR_EXCHANGERATETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATECURRENCYPAIR] ADD  CONSTRAINT [DF_EXCHANGERATECURRENCYPAIR_EXCHANGERATETYPE]  DEFAULT ((0)) FOR [EXCHANGERATETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATECURRENCYPAIR_FROMCURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATECURRENCYPAIR] ADD  CONSTRAINT [DF_EXCHANGERATECURRENCYPAIR_FROMCURRENCYCODE]  DEFAULT ('') FOR [FROMCURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATECURRENCYPAIR_TOCURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATECURRENCYPAIR] ADD  CONSTRAINT [DF_EXCHANGERATECURRENCYPAIR_TOCURRENCYCODE]  DEFAULT ('') FOR [TOCURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATECURRENCYPAIR_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATECURRENCYPAIR] ADD  CONSTRAINT [DF_EXCHANGERATECURRENCYPAIR_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[EXCHANGERATECURRENCYPAIR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[EXCHANGERATETYPE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[EXCHANGERATETYPE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[NAME] [nvarchar](20) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-193334427_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-193334427_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATETYPE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATETYPE] ADD  CONSTRAINT [DF_EXCHANGERATETYPE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_EXCHANGERATETYPE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[EXCHANGERATETYPE] ADD  CONSTRAINT [DF_EXCHANGERATETYPE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[EXCHANGERATETYPE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[FISCALESTABLISHMENT_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[FISCALESTABLISHMENT_BR](
[RECID] [bigint] NOT NULL,
[ACCOUNTANT_BR] [bigint] NOT NULL,
[CCMNUM_BR] [nvarchar](20) NOT NULL,
[CNPJCPFNUM_BR] [nvarchar](20) NOT NULL,
[DIRPARTYLOCATION] [bigint] NOT NULL,
[FISCALESTABLISHMENTID] [nvarchar](10) NOT NULL,
[IENUM_BR] [nvarchar](20) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1629009360_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1629009360_1165620475] UNIQUE NONCLUSTERED 
(
[FISCALESTABLISHMENTID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1629009360_1402367493] UNIQUE NONCLUSTERED 
(
[DIRPARTYLOCATION] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_ACCOUNTANT_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_ACCOUNTANT_BR]  DEFAULT ((0)) FOR [ACCOUNTANT_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_CCMNUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_CCMNUM_BR]  DEFAULT ('') FOR [CCMNUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_CNPJCPFNUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_CNPJCPFNUM_BR]  DEFAULT ('') FOR [CNPJCPFNUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_DIRPARTYLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_DIRPARTYLOCATION]  DEFAULT ((0)) FOR [DIRPARTYLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_FISCALESTABLISHMENTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_FISCALESTABLISHMENTID]  DEFAULT ('') FOR [FISCALESTABLISHMENTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_IENUM_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_IENUM_BR]  DEFAULT ('') FOR [IENUM_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENT_BR_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENT_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENT_BR_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[FISCALESTABLISHMENT_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[FISCALESTABLISHMENTINVENTSITE_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[FISCALESTABLISHMENTINVENTSITE_BR](
[RECID] [bigint] NOT NULL,
[FISCALESTABLISHMENT_BR] [bigint] NOT NULL,
[INVENTSITE] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1215761809_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1215761809_-1854860068] UNIQUE NONCLUSTERED 
(
[INVENTSITE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENTINVENTSITE_BR_FISCALESTABLISHMENT_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENTINVENTSITE_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENTINVENTSITE_BR_FISCALESTABLISHMENT_BR]  DEFAULT ((0)) FOR [FISCALESTABLISHMENT_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FISCALESTABLISHMENTINVENTSITE_BR_INVENTSITE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FISCALESTABLISHMENTINVENTSITE_BR] ADD  CONSTRAINT [DF_FISCALESTABLISHMENTINVENTSITE_BR_INVENTSITE]  DEFAULT ('') FOR [INVENTSITE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[FISCALESTABLISHMENTINVENTSITE_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[FORMULADESIGNER_IN]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[FORMULADESIGNER_IN](
[RECID] [bigint] NOT NULL,
[CALCEXP] [nvarchar](1000) NOT NULL,
[CALCEXP1] [nvarchar](1000) NOT NULL,
[ID] [int] NOT NULL,
[PRICEINCLTAX] [int] NOT NULL,
[TAXABLEBASIS] [int] NOT NULL,
[TAXCODE] [nvarchar](10) NOT NULL,
[TAXITEMGROUP] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-751993433_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-751993433_-2114646326] UNIQUE NONCLUSTERED 
(
[TAXITEMGROUP] ASC,
[TAXCODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_CALCEXP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_CALCEXP]  DEFAULT ('') FOR [CALCEXP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_CALCEXP1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_CALCEXP1]  DEFAULT ('') FOR [CALCEXP1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_ID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_ID]  DEFAULT ((0)) FOR [ID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_PRICEINCLTAX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_PRICEINCLTAX]  DEFAULT ((0)) FOR [PRICEINCLTAX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_TAXABLEBASIS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_TAXABLEBASIS]  DEFAULT ((0)) FOR [TAXABLEBASIS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_TAXCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_TAXCODE]  DEFAULT ('') FOR [TAXCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_FORMULADESIGNER_IN_TAXITEMGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[FORMULADESIGNER_IN] ADD  CONSTRAINT [DF_FORMULADESIGNER_IN_TAXITEMGROUP]  DEFAULT ('') FOR [TAXITEMGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[FORMULADESIGNER_IN] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[HCMJOB]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[HCMJOB](
[RECID] [bigint] NOT NULL,
[JOBID] [nvarchar](25) NOT NULL,
[MAXIMUMPOSITIONS] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1678374987_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1678374987_-689341552] UNIQUE NONCLUSTERED 
(
[JOBID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMJOB_JOBID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMJOB] ADD  CONSTRAINT [DF_HCMJOB_JOBID]  DEFAULT ('') FOR [JOBID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMJOB_MAXIMUMPOSITIONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMJOB] ADD  CONSTRAINT [DF_HCMJOB_MAXIMUMPOSITIONS]  DEFAULT ((0)) FOR [MAXIMUMPOSITIONS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMJOB_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMJOB] ADD  CONSTRAINT [DF_HCMJOB_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMJOB_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMJOB] ADD  CONSTRAINT [DF_HCMJOB_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[HCMJOB] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[HCMPOSITION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[HCMPOSITION](
[RECID] [bigint] NOT NULL,
[POSITIONID] [nvarchar](25) NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_592131255_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_592131255_-1568444020] UNIQUE NONCLUSTERED 
(
[POSITIONID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITION_POSITIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITION] ADD  CONSTRAINT [DF_HCMPOSITION_POSITIONID]  DEFAULT ('') FOR [POSITIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITION_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITION] ADD  CONSTRAINT [DF_HCMPOSITION_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITION_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITION] ADD  CONSTRAINT [DF_HCMPOSITION_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[HCMPOSITION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[HCMPOSITIONDETAIL]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[HCMPOSITIONDETAIL](
[RECID] [bigint] NOT NULL,
[COMPLOCATION] [bigint] NOT NULL,
[DEPARTMENT] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[FULLTIMEEQUIVALENCY] [numeric](32, 16) NOT NULL,
[JOB] [bigint] NOT NULL,
[POSITION] [bigint] NOT NULL,
[POSITIONTYPE] [bigint] NOT NULL,
[TITLE] [bigint] NOT NULL,
[VALIDFROM] [datetime] NOT NULL,
[VALIDFROMTZID] [int] NOT NULL,
[VALIDTO] [datetime] NOT NULL,
[VALIDTOTZID] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1550564396_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1550564396_-1568444020] UNIQUE NONCLUSTERED 
(
[POSITION] ASC,
[VALIDFROM] ASC,
[VALIDTO] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_COMPLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_COMPLOCATION]  DEFAULT ((0)) FOR [COMPLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_DEPARTMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_DEPARTMENT]  DEFAULT ((0)) FOR [DEPARTMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_FULLTIMEEQUIVALENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_FULLTIMEEQUIVALENCY]  DEFAULT ((0)) FOR [FULLTIMEEQUIVALENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_JOB]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_JOB]  DEFAULT ((0)) FOR [JOB]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_POSITION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_POSITION]  DEFAULT ((0)) FOR [POSITION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_POSITIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_POSITIONTYPE]  DEFAULT ((0)) FOR [POSITIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_TITLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_TITLE]  DEFAULT ((0)) FOR [TITLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_VALIDFROM]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_VALIDFROMTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_VALIDFROMTZID]  DEFAULT ((37001)) FOR [VALIDFROMTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_VALIDTO]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_VALIDTOTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_VALIDTOTZID]  DEFAULT ((37001)) FOR [VALIDTOTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONDETAIL_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONDETAIL] ADD  CONSTRAINT [DF_HCMPOSITIONDETAIL_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[HCMPOSITIONDETAIL] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[HCMPOSITIONWORKERASSIGNMENT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT](
[RECID] [bigint] NOT NULL,
[ASSIGNMENTREASONCODE] [bigint] NOT NULL,
[POSITION] [bigint] NOT NULL,
[VALIDFROM] [datetime] NOT NULL,
[VALIDFROMTZID] [int] NOT NULL,
[VALIDTO] [datetime] NOT NULL,
[VALIDTOTZID] [int] NOT NULL,
[WORKER] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1725185210_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1725185210_-1568444020] UNIQUE NONCLUSTERED 
(
[POSITION] ASC,
[VALIDFROM] ASC,
[VALIDTO] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_ASSIGNMENTREASONCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_ASSIGNMENTREASONCODE]  DEFAULT ((0)) FOR [ASSIGNMENTREASONCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_POSITION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_POSITION]  DEFAULT ((0)) FOR [POSITION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_VALIDFROM]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_VALIDFROMTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_VALIDFROMTZID]  DEFAULT ((37001)) FOR [VALIDFROMTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_VALIDTO]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_VALIDTOTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_VALIDTOTZID]  DEFAULT ((37001)) FOR [VALIDTOTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_WORKER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_WORKER]  DEFAULT ((0)) FOR [WORKER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMPOSITIONWORKERASSIGNMENT_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMPOSITIONWORKERASSIGNMENT] ADD  CONSTRAINT [DF_HCMPOSITIONWORKERASSIGNMENT_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[HCMPOSITIONWORKERASSIGNMENT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[HCMWORKER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[HCMWORKER](
[RECID] [bigint] NOT NULL,
[PERSON] [bigint] NOT NULL,
[PERSONNELNUMBER] [nvarchar](25) NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_876116916_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_876116916_-738480416] UNIQUE NONCLUSTERED 
(
[PERSON] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_876116916_-738480417] UNIQUE NONCLUSTERED 
(
[PERSONNELNUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMWORKER_PERSON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMWORKER] ADD  CONSTRAINT [DF_HCMWORKER_PERSON]  DEFAULT ((0)) FOR [PERSON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMWORKER_PERSONNELNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMWORKER] ADD  CONSTRAINT [DF_HCMWORKER_PERSONNELNUMBER]  DEFAULT ('') FOR [PERSONNELNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMWORKER_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMWORKER] ADD  CONSTRAINT [DF_HCMWORKER_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_HCMWORKER_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[HCMWORKER] ADD  CONSTRAINT [DF_HCMWORKER_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[HCMWORKER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTDIM]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTDIM](
[RECID] [bigint] NOT NULL,
[CONFIGID] [nvarchar](10) NOT NULL,
[INVENTBATCHID] [nvarchar](20) NOT NULL,
[INVENTCOLORID] [nvarchar](10) NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[INVENTGTDID_RU] [nvarchar](30) NOT NULL,
[INVENTLOCATIONID] [nvarchar](10) NOT NULL,
[INVENTOWNERID_RU] [nvarchar](20) NOT NULL,
[INVENTPROFILEID_RU] [nvarchar](10) NOT NULL,
[INVENTSERIALID] [nvarchar](20) NOT NULL,
[INVENTSITEID] [nvarchar](10) NOT NULL,
[INVENTSIZEID] [nvarchar](10) NOT NULL,
[INVENTSTYLEID] [nvarchar](10) NOT NULL,
[SHA1HASH] [varbinary](28) NULL,
[WMSLOCATIONID] [nvarchar](10) NOT NULL,
[WMSPALLETID] [nvarchar](18) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-65082180_-588450352] PRIMARY KEY CLUSTERED 
(
[INVENTDIMID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-65082180_-851492679] UNIQUE NONCLUSTERED 
(
[CONFIGID] ASC,
[INVENTSIZEID] ASC,
[INVENTCOLORID] ASC,
[INVENTSTYLEID] ASC,
[INVENTSITEID] ASC,
[INVENTLOCATIONID] ASC,
[INVENTBATCHID] ASC,
[WMSLOCATIONID] ASC,
[WMSPALLETID] ASC,
[INVENTSERIALID] ASC,
[INVENTGTDID_RU] ASC,
[INVENTPROFILEID_RU] ASC,
[INVENTOWNERID_RU] ASC,
[SHA1HASH] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_CONFIGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_CONFIGID]  DEFAULT ('') FOR [CONFIGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTBATCHID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTBATCHID]  DEFAULT ('') FOR [INVENTBATCHID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTCOLORID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTCOLORID]  DEFAULT ('') FOR [INVENTCOLORID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTGTDID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTGTDID_RU]  DEFAULT ('') FOR [INVENTGTDID_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTLOCATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTLOCATIONID]  DEFAULT ('') FOR [INVENTLOCATIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTOWNERID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTOWNERID_RU]  DEFAULT ('') FOR [INVENTOWNERID_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTPROFILEID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTPROFILEID_RU]  DEFAULT ('') FOR [INVENTPROFILEID_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTSERIALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTSERIALID]  DEFAULT ('') FOR [INVENTSERIALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTSITEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTSITEID]  DEFAULT ('') FOR [INVENTSITEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTSIZEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTSIZEID]  DEFAULT ('') FOR [INVENTSIZEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_INVENTSTYLEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_INVENTSTYLEID]  DEFAULT ('') FOR [INVENTSTYLEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_WMSLOCATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_WMSLOCATIONID]  DEFAULT ('') FOR [WMSLOCATIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIM_WMSPALLETID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIM] ADD  CONSTRAINT [DF_INVENTDIM_WMSPALLETID]  DEFAULT ('') FOR [WMSPALLETID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTDIM] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTDIMCOMBINATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTDIMCOMBINATION](
[RECID] [bigint] NOT NULL,
[DISTINCTPRODUCTVARIANT] [bigint] NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[RETAILVARIANTID] [nvarchar](10) NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-804010625_1429128816] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[INVENTDIMID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-804010625_-474954108] UNIQUE NONCLUSTERED 
(
[DISTINCTPRODUCTVARIANT] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIMCOMBINATION_DISTINCTPRODUCTVARIANT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIMCOMBINATION] ADD  CONSTRAINT [DF_INVENTDIMCOMBINATION_DISTINCTPRODUCTVARIANT]  DEFAULT ((0)) FOR [DISTINCTPRODUCTVARIANT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIMCOMBINATION_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIMCOMBINATION] ADD  CONSTRAINT [DF_INVENTDIMCOMBINATION_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIMCOMBINATION_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIMCOMBINATION] ADD  CONSTRAINT [DF_INVENTDIMCOMBINATION_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIMCOMBINATION_RETAILVARIANTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIMCOMBINATION] ADD  CONSTRAINT [DF_INVENTDIMCOMBINATION_RETAILVARIANTID]  DEFAULT ('') FOR [RETAILVARIANTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTDIMCOMBINATION_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTDIMCOMBINATION] ADD  CONSTRAINT [DF_INVENTDIMCOMBINATION_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTDIMCOMBINATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTITEMBARCODE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTITEMBARCODE](
[RECID] [bigint] NOT NULL,
[BARCODESETUPID] [nvarchar](10) NOT NULL,
[BLOCKED] [int] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[ITEMBARCODE] [nvarchar](80) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[QTY] [numeric](32, 16) NOT NULL,
[RETAILSHOWFORITEM] [int] NOT NULL,
[RETAILVARIANTID] [nvarchar](10) NOT NULL,
[UNITID] [nvarchar](10) NOT NULL,
[USEFORINPUT] [int] NOT NULL,
[USEFORPRINTING] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_500758235_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_BARCODESETUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_BARCODESETUPID]  DEFAULT ('') FOR [BARCODESETUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_BLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_BLOCKED]  DEFAULT ((0)) FOR [BLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_ITEMBARCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_ITEMBARCODE]  DEFAULT ('') FOR [ITEMBARCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_RETAILSHOWFORITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_RETAILSHOWFORITEM]  DEFAULT ((0)) FOR [RETAILSHOWFORITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_RETAILVARIANTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_RETAILVARIANTID]  DEFAULT ('') FOR [RETAILVARIANTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_UNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_UNITID]  DEFAULT ('') FOR [UNITID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_USEFORINPUT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_USEFORINPUT]  DEFAULT ((0)) FOR [USEFORINPUT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMBARCODE_USEFORPRINTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMBARCODE] ADD  CONSTRAINT [DF_INVENTITEMBARCODE_USEFORPRINTING]  DEFAULT ((0)) FOR [USEFORPRINTING]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTITEMBARCODE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTITEMGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTITEMGROUP](
[RECID] [bigint] NOT NULL,
[ITEMGROUPID] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1805098484_2044944007] PRIMARY KEY CLUSTERED 
(
[ITEMGROUPID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGROUP_ITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGROUP] ADD  CONSTRAINT [DF_INVENTITEMGROUP_ITEMGROUPID]  DEFAULT ('') FOR [ITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGROUP_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGROUP] ADD  CONSTRAINT [DF_INVENTITEMGROUP_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTITEMGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTITEMGROUPITEM]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTITEMGROUPITEM](
[RECID] [bigint] NOT NULL,
[ITEMDATAAREAID] [nvarchar](4) NOT NULL,
[ITEMGROUPDATAAREAID] [nvarchar](4) NOT NULL,
[ITEMGROUPID] [nvarchar](10) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-313455423_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-313455423_1429128816] UNIQUE NONCLUSTERED 
(
[ITEMID] ASC,
[ITEMDATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGROUPITEM_ITEMDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGROUPITEM] ADD  CONSTRAINT [DF_INVENTITEMGROUPITEM_ITEMDATAAREAID]  DEFAULT ('') FOR [ITEMDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGROUPITEM_ITEMGROUPDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGROUPITEM] ADD  CONSTRAINT [DF_INVENTITEMGROUPITEM_ITEMGROUPDATAAREAID]  DEFAULT ('') FOR [ITEMGROUPDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGROUPITEM_ITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGROUPITEM] ADD  CONSTRAINT [DF_INVENTITEMGROUPITEM_ITEMGROUPID]  DEFAULT ('') FOR [ITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGROUPITEM_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGROUPITEM] ADD  CONSTRAINT [DF_INVENTITEMGROUPITEM_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTITEMGROUPITEM] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTITEMGTIN]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTITEMGTIN](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[GLOBALTRADEITEMNUMBER] [nvarchar](14) NOT NULL,
[GTINSETUP] [int] NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[UNITID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1261397331_1429128816] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[INVENTDIMID] ASC,
[UNITID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1261397331_-948205258] UNIQUE NONCLUSTERED 
(
[GLOBALTRADEITEMNUMBER] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGTIN_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGTIN] ADD  CONSTRAINT [DF_INVENTITEMGTIN_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGTIN_GLOBALTRADEITEMNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGTIN] ADD  CONSTRAINT [DF_INVENTITEMGTIN_GLOBALTRADEITEMNUMBER]  DEFAULT ('') FOR [GLOBALTRADEITEMNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGTIN_GTINSETUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGTIN] ADD  CONSTRAINT [DF_INVENTITEMGTIN_GTINSETUP]  DEFAULT ((0)) FOR [GTINSETUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGTIN_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGTIN] ADD  CONSTRAINT [DF_INVENTITEMGTIN_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGTIN_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGTIN] ADD  CONSTRAINT [DF_INVENTITEMGTIN_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMGTIN_UNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMGTIN] ADD  CONSTRAINT [DF_INVENTITEMGTIN_UNITID]  DEFAULT ('') FOR [UNITID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTITEMGTIN] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTITEMSALESSETUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTITEMSALESSETUP](
[RECID] [bigint] NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[INVENTDIMIDDEFAULT] [nvarchar](20) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[MANDATORYINVENTLOCATION] [int] NOT NULL,
[MANDATORYINVENTSITE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1618439284_1798859704] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[INVENTDIMID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMSALESSETUP_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMSALESSETUP] ADD  CONSTRAINT [DF_INVENTITEMSALESSETUP_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMSALESSETUP_INVENTDIMIDDEFAULT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMSALESSETUP] ADD  CONSTRAINT [DF_INVENTITEMSALESSETUP_INVENTDIMIDDEFAULT]  DEFAULT ('') FOR [INVENTDIMIDDEFAULT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMSALESSETUP_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMSALESSETUP] ADD  CONSTRAINT [DF_INVENTITEMSALESSETUP_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMSALESSETUP_MANDATORYINVENTLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMSALESSETUP] ADD  CONSTRAINT [DF_INVENTITEMSALESSETUP_MANDATORYINVENTLOCATION]  DEFAULT ((0)) FOR [MANDATORYINVENTLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTITEMSALESSETUP_MANDATORYINVENTSITE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTITEMSALESSETUP] ADD  CONSTRAINT [DF_INVENTITEMSALESSETUP_MANDATORYINVENTSITE]  DEFAULT ((0)) FOR [MANDATORYINVENTSITE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTITEMSALESSETUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTLOCATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTLOCATION](
[RECID] [bigint] NOT NULL,
[INVENTLOCATIONID] [nvarchar](10) NOT NULL,
[INVENTLOCATIONTYPE] [int] NOT NULL,
[INVENTSITEID] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_448739807_1141804996] PRIMARY KEY CLUSTERED 
(
[INVENTLOCATIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATION_INVENTLOCATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATION_INVENTLOCATIONID]  DEFAULT ('') FOR [INVENTLOCATIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATION_INVENTLOCATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATION_INVENTLOCATIONTYPE]  DEFAULT ((0)) FOR [INVENTLOCATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATION_INVENTSITEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATION_INVENTSITEID]  DEFAULT ('') FOR [INVENTSITEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATION_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATION_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTLOCATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTLOCATIONLOGISTICSLOCATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTLOCATIONLOGISTICSLOCATION](
[RECID] [bigint] NOT NULL,
[INVENTLOCATION] [bigint] NOT NULL,
[ISPOSTALADDRESS] [int] NOT NULL,
[ISPRIMARY] [int] NOT NULL,
[LOCATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1407999417_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1407999417_553911634] UNIQUE NONCLUSTERED 
(
[INVENTLOCATION] ASC,
[LOCATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATIONLOGISTICSLOCATION_INVENTLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATIONLOGISTICSLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATIONLOGISTICSLOCATION_INVENTLOCATION]  DEFAULT ((0)) FOR [INVENTLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATIONLOGISTICSLOCATION_ISPOSTALADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATIONLOGISTICSLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATIONLOGISTICSLOCATION_ISPOSTALADDRESS]  DEFAULT ((0)) FOR [ISPOSTALADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATIONLOGISTICSLOCATION_ISPRIMARY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATIONLOGISTICSLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATIONLOGISTICSLOCATION_ISPRIMARY]  DEFAULT ((0)) FOR [ISPRIMARY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTLOCATIONLOGISTICSLOCATION_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTLOCATIONLOGISTICSLOCATION] ADD  CONSTRAINT [DF_INVENTLOCATIONLOGISTICSLOCATION_LOCATION]  DEFAULT ((0)) FOR [LOCATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTLOCATIONLOGISTICSLOCATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTSERIAL]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTSERIAL](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](max) NULL,
[INVENTSERIALID] [nvarchar](20) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[PRODDATE] [date] NOT NULL,
[RFIDTAGID] [nvarchar](24) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_43867350_-846934704] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[INVENTSERIALID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTSERIAL_INVENTSERIALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTSERIAL] ADD  CONSTRAINT [DF_INVENTSERIAL_INVENTSERIALID]  DEFAULT ('') FOR [INVENTSERIALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTSERIAL_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTSERIAL] ADD  CONSTRAINT [DF_INVENTSERIAL_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTSERIAL_PRODDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTSERIAL] ADD  CONSTRAINT [DF_INVENTSERIAL_PRODDATE]  DEFAULT ('1900-01-01') FOR [PRODDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTSERIAL_RFIDTAGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTSERIAL] ADD  CONSTRAINT [DF_INVENTSERIAL_RFIDTAGID]  DEFAULT ('') FOR [RFIDTAGID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTSERIAL] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTTABLE](
[RECID] [bigint] NOT NULL,
[ABCCONTRIBUTIONMARGIN] [int] NOT NULL,
[ABCREVENUE] [int] NOT NULL,
[ABCTIEUP] [int] NOT NULL,
[ABCVALUE] [int] NOT NULL,
[ALTITEMID] [nvarchar](20) NOT NULL,
[APPROXTAXVALUE_BR] [numeric](32, 16) NOT NULL,
[BATCHNUMGROUPID] [nvarchar](10) NOT NULL,
[COSTMODEL] [int] NOT NULL,
[DENSITY] [numeric](32, 16) NOT NULL,
[DEPTH] [numeric](32, 16) NOT NULL,
[EXCEPTIONCODE_BR] [nvarchar](10) NOT NULL,
[GROSSDEPTH] [numeric](32, 16) NOT NULL,
[GROSSHEIGHT] [numeric](32, 16) NOT NULL,
[GROSSWIDTH] [numeric](32, 16) NOT NULL,
[HEIGHT] [numeric](32, 16) NOT NULL,
[INVENTPRODUCTTYPE_BR] [nvarchar](10) NOT NULL,
[ITEMBUYERGROUPID] [nvarchar](10) NOT NULL,
[ITEMDIMCOSTPRICE] [int] NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[ITEMTYPE] [int] NOT NULL,
[NAMEALIAS] [nvarchar](20) NOT NULL,
[NETWEIGHT] [numeric](32, 16) NOT NULL,
[PBAINVENTITEMGROUPID] [nvarchar](10) NOT NULL,
[PBAITEMCONFIGURABLE] [int] NOT NULL,
[PRIMARYVENDORID] [nvarchar](20) NOT NULL,
[PRODGROUPID] [nvarchar](10) NOT NULL,
[PRODPOOLID] [nvarchar](10) NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[PROJCATEGORYID] [nvarchar](30) NOT NULL,
[PROPERTYID] [nvarchar](10) NOT NULL,
[PURCHMODEL] [int] NOT NULL,
[REQGROUPID] [nvarchar](10) NOT NULL,
[SALESCONTRIBUTIONRATIO] [numeric](32, 16) NOT NULL,
[SALESMODEL] [int] NOT NULL,
[SALESPERCENTMARKUP] [numeric](32, 16) NOT NULL,
[SALESPRICEMODELBASIC] [int] NOT NULL,
[SERIALNUMGROUPID] [nvarchar](10) NOT NULL,
[SORTCODE] [int] NOT NULL,
[TARAWEIGHT] [numeric](32, 16) NOT NULL,
[TAXATIONORIGIN_BR] [int] NOT NULL,
[TAXFISCALCLASSIFICATION_BR] [nvarchar](10) NOT NULL,
[TAXSERVICECODE_BR] [nvarchar](10) NOT NULL,
[UNITVOLUME] [numeric](32, 16) NOT NULL,
[USEALTITEMID] [int] NOT NULL,
[WIDTH] [numeric](32, 16) NOT NULL,
[WMSPICKINGQTYTIME] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-137955366_1429128816] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-137955366_-474954108] UNIQUE NONCLUSTERED 
(
[PRODUCT] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ABCCONTRIBUTIONMARGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ABCCONTRIBUTIONMARGIN]  DEFAULT ((0)) FOR [ABCCONTRIBUTIONMARGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ABCREVENUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ABCREVENUE]  DEFAULT ((0)) FOR [ABCREVENUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ABCTIEUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ABCTIEUP]  DEFAULT ((0)) FOR [ABCTIEUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ABCVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ABCVALUE]  DEFAULT ((0)) FOR [ABCVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ALTITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ALTITEMID]  DEFAULT ('') FOR [ALTITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_APPROXTAXVALUE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_APPROXTAXVALUE_BR]  DEFAULT ((0)) FOR [APPROXTAXVALUE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_BATCHNUMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_BATCHNUMGROUPID]  DEFAULT ('') FOR [BATCHNUMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_COSTMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_COSTMODEL]  DEFAULT ((0)) FOR [COSTMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_DENSITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_DENSITY]  DEFAULT ((0)) FOR [DENSITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_DEPTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_DEPTH]  DEFAULT ((0)) FOR [DEPTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_EXCEPTIONCODE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_EXCEPTIONCODE_BR]  DEFAULT ('') FOR [EXCEPTIONCODE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_GROSSDEPTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_GROSSDEPTH]  DEFAULT ((0)) FOR [GROSSDEPTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_GROSSHEIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_GROSSHEIGHT]  DEFAULT ((0)) FOR [GROSSHEIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_GROSSWIDTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_GROSSWIDTH]  DEFAULT ((0)) FOR [GROSSWIDTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_HEIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_HEIGHT]  DEFAULT ((0)) FOR [HEIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_INVENTPRODUCTTYPE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_INVENTPRODUCTTYPE_BR]  DEFAULT ('') FOR [INVENTPRODUCTTYPE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ITEMBUYERGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ITEMBUYERGROUPID]  DEFAULT ('') FOR [ITEMBUYERGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ITEMDIMCOSTPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ITEMDIMCOSTPRICE]  DEFAULT ((0)) FOR [ITEMDIMCOSTPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_ITEMTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_ITEMTYPE]  DEFAULT ((0)) FOR [ITEMTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_NAMEALIAS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_NAMEALIAS]  DEFAULT ('') FOR [NAMEALIAS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_NETWEIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_NETWEIGHT]  DEFAULT ((0)) FOR [NETWEIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PBAINVENTITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PBAINVENTITEMGROUPID]  DEFAULT ('') FOR [PBAINVENTITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PBAITEMCONFIGURABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PBAITEMCONFIGURABLE]  DEFAULT ((0)) FOR [PBAITEMCONFIGURABLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PRIMARYVENDORID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PRIMARYVENDORID]  DEFAULT ('') FOR [PRIMARYVENDORID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PRODGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PRODGROUPID]  DEFAULT ('') FOR [PRODGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PRODPOOLID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PRODPOOLID]  DEFAULT ('') FOR [PRODPOOLID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PROJCATEGORYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PROJCATEGORYID]  DEFAULT ('') FOR [PROJCATEGORYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PROPERTYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PROPERTYID]  DEFAULT ('') FOR [PROPERTYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_PURCHMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_PURCHMODEL]  DEFAULT ((0)) FOR [PURCHMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_REQGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_REQGROUPID]  DEFAULT ('') FOR [REQGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_SALESCONTRIBUTIONRATIO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_SALESCONTRIBUTIONRATIO]  DEFAULT ((0)) FOR [SALESCONTRIBUTIONRATIO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_SALESMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_SALESMODEL]  DEFAULT ((0)) FOR [SALESMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_SALESPERCENTMARKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_SALESPERCENTMARKUP]  DEFAULT ((0)) FOR [SALESPERCENTMARKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_SALESPRICEMODELBASIC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_SALESPRICEMODELBASIC]  DEFAULT ((0)) FOR [SALESPRICEMODELBASIC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_SERIALNUMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_SERIALNUMGROUPID]  DEFAULT ('') FOR [SERIALNUMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_SORTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_SORTCODE]  DEFAULT ((0)) FOR [SORTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_TARAWEIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_TARAWEIGHT]  DEFAULT ((0)) FOR [TARAWEIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_TAXATIONORIGIN_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_TAXATIONORIGIN_BR]  DEFAULT ((0)) FOR [TAXATIONORIGIN_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_TAXFISCALCLASSIFICATION_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_TAXFISCALCLASSIFICATION_BR]  DEFAULT ('') FOR [TAXFISCALCLASSIFICATION_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_TAXSERVICECODE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_TAXSERVICECODE_BR]  DEFAULT ('') FOR [TAXSERVICECODE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_UNITVOLUME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_UNITVOLUME]  DEFAULT ((0)) FOR [UNITVOLUME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_USEALTITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_USEALTITEMID]  DEFAULT ((0)) FOR [USEALTITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_WIDTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_WIDTH]  DEFAULT ((0)) FOR [WIDTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLE_WMSPICKINGQTYTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLE] ADD  CONSTRAINT [DF_INVENTTABLE_WMSPICKINGQTYTIME]  DEFAULT ((0)) FOR [WMSPICKINGQTYTIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[INVENTTABLEMODULE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[INVENTTABLEMODULE](
[RECID] [bigint] NOT NULL,
[ALLOCATEMARKUP] [int] NOT NULL,
[ENDDISC] [int] NOT NULL,
[INTERCOMPANYBLOCKED] [int] NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[LINEDISC] [nvarchar](10) NOT NULL,
[MARKUP] [numeric](32, 16) NOT NULL,
[MARKUPGROUPID] [nvarchar](10) NOT NULL,
[MAXIMUMRETAILPRICE_IN] [numeric](32, 16) NOT NULL,
[MODULETYPE] [int] NOT NULL,
[MULTILINEDISC] [nvarchar](10) NOT NULL,
[OVERDELIVERYPCT] [numeric](32, 16) NOT NULL,
[PRICE] [numeric](32, 16) NOT NULL,
[PRICEDATE] [date] NOT NULL,
[PRICEQTY] [numeric](32, 16) NOT NULL,
[PRICEUNIT] [numeric](32, 16) NOT NULL,
[SUPPITEMGROUPID] [nvarchar](10) NOT NULL,
[TAXITEMGROUPID] [nvarchar](10) NOT NULL,
[UNDERDELIVERYPCT] [numeric](32, 16) NOT NULL,
[UNITID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1890880046_1242579072] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[MODULETYPE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_ALLOCATEMARKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_ALLOCATEMARKUP]  DEFAULT ((0)) FOR [ALLOCATEMARKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_ENDDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_ENDDISC]  DEFAULT ((0)) FOR [ENDDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_INTERCOMPANYBLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_INTERCOMPANYBLOCKED]  DEFAULT ((0)) FOR [INTERCOMPANYBLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_LINEDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_LINEDISC]  DEFAULT ('') FOR [LINEDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_MARKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_MARKUP]  DEFAULT ((0)) FOR [MARKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_MARKUPGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_MARKUPGROUPID]  DEFAULT ('') FOR [MARKUPGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_MAXIMUMRETAILPRICE_IN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_MAXIMUMRETAILPRICE_IN]  DEFAULT ((0)) FOR [MAXIMUMRETAILPRICE_IN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_MODULETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_MODULETYPE]  DEFAULT ((0)) FOR [MODULETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_MULTILINEDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_MULTILINEDISC]  DEFAULT ('') FOR [MULTILINEDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_OVERDELIVERYPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_OVERDELIVERYPCT]  DEFAULT ((0)) FOR [OVERDELIVERYPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_PRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_PRICE]  DEFAULT ((0)) FOR [PRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_PRICEDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_PRICEDATE]  DEFAULT ('1900-01-01') FOR [PRICEDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_PRICEQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_PRICEQTY]  DEFAULT ((0)) FOR [PRICEQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_PRICEUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_PRICEUNIT]  DEFAULT ((0)) FOR [PRICEUNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_SUPPITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_SUPPITEMGROUPID]  DEFAULT ('') FOR [SUPPITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_TAXITEMGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_TAXITEMGROUPID]  DEFAULT ('') FOR [TAXITEMGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_UNDERDELIVERYPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_UNDERDELIVERYPCT]  DEFAULT ((0)) FOR [UNDERDELIVERYPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_INVENTTABLEMODULE_UNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[INVENTTABLEMODULE] ADD  CONSTRAINT [DF_INVENTTABLEMODULE_UNITID]  DEFAULT ('') FOR [UNITID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[INVENTTABLEMODULE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[JMGIPCACTIVITY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[JMGIPCACTIVITY](
[RECID] [bigint] NOT NULL,
[ACTIVITY] [nvarchar](10) NOT NULL,
[BREAKDROP] [int] NOT NULL,
[CATEGORY] [nvarchar](10) NOT NULL,
[JOBID] [nvarchar](20) NOT NULL,
[SIGNIN] [int] NOT NULL,
[SIGNINOUT] [int] NOT NULL,
[TYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-765664409_828124743] PRIMARY KEY CLUSTERED 
(
[ACTIVITY] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-765664409_1805009001] UNIQUE NONCLUSTERED 
(
[CATEGORY] ASC,
[ACTIVITY] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-765664409_-937149049] UNIQUE NONCLUSTERED 
(
[JOBID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_ACTIVITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_ACTIVITY]  DEFAULT ('') FOR [ACTIVITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_BREAKDROP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_BREAKDROP]  DEFAULT ((0)) FOR [BREAKDROP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_CATEGORY]  DEFAULT ('') FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_JOBID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_JOBID]  DEFAULT ('') FOR [JOBID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_SIGNIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_SIGNIN]  DEFAULT ((0)) FOR [SIGNIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_SIGNINOUT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_SIGNINOUT]  DEFAULT ((0)) FOR [SIGNINOUT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_JMGIPCACTIVITY_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[JMGIPCACTIVITY] ADD  CONSTRAINT [DF_JMGIPCACTIVITY_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[JMGIPCACTIVITY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LANGUAGETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LANGUAGETABLE](
[RECID] [bigint] NOT NULL,
[LABELFILE] [int] NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[USERDEFINEDLANGUAGE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1680185576_-1273337705] PRIMARY KEY CLUSTERED 
(
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LANGUAGETABLE_LABELFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LANGUAGETABLE] ADD  CONSTRAINT [DF_LANGUAGETABLE_LABELFILE]  DEFAULT ((0)) FOR [LABELFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LANGUAGETABLE_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LANGUAGETABLE] ADD  CONSTRAINT [DF_LANGUAGETABLE_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LANGUAGETABLE_USERDEFINEDLANGUAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LANGUAGETABLE] ADD  CONSTRAINT [DF_LANGUAGETABLE_USERDEFINEDLANGUAGE]  DEFAULT ((0)) FOR [USERDEFINEDLANGUAGE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LANGUAGETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LEDGER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LEDGER](
[RECID] [bigint] NOT NULL,
[ACCOUNTINGCURRENCY] [nvarchar](3) NOT NULL,
[BUDGETEXCHANGERATETYPE] [bigint] NOT NULL,
[CHARTOFACCOUNTS] [bigint] NOT NULL,
[DEFAULTEXCHANGERATETYPE] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[FISCALCALENDAR] [bigint] NOT NULL,
[ISBUDGETCONTROLENABLED] [int] NOT NULL,
[NAME] [nvarchar](20) NOT NULL,
[PRIMARYFORLEGALENTITY] [bigint] NOT NULL,
[REPORTINGCURRENCY] [nvarchar](3) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-103131727_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-103131727_-1565480838] UNIQUE NONCLUSTERED 
(
[PRIMARYFORLEGALENTITY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-103131727_-1966747349] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_ACCOUNTINGCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_ACCOUNTINGCURRENCY]  DEFAULT ('') FOR [ACCOUNTINGCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_BUDGETEXCHANGERATETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_BUDGETEXCHANGERATETYPE]  DEFAULT ((0)) FOR [BUDGETEXCHANGERATETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_CHARTOFACCOUNTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_CHARTOFACCOUNTS]  DEFAULT ((0)) FOR [CHARTOFACCOUNTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_DEFAULTEXCHANGERATETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_DEFAULTEXCHANGERATETYPE]  DEFAULT ((0)) FOR [DEFAULTEXCHANGERATETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_FISCALCALENDAR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_FISCALCALENDAR]  DEFAULT ((0)) FOR [FISCALCALENDAR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_ISBUDGETCONTROLENABLED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_ISBUDGETCONTROLENABLED]  DEFAULT ((0)) FOR [ISBUDGETCONTROLENABLED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_PRIMARYFORLEGALENTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_PRIMARYFORLEGALENTITY]  DEFAULT ((0)) FOR [PRIMARYFORLEGALENTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LEDGER_REPORTINGCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LEDGER] ADD  CONSTRAINT [DF_LEDGER_REPORTINGCURRENCY]  DEFAULT ('') FOR [REPORTINGCURRENCY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LEDGER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSCOUNTRYREGION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION](
[RECID] [bigint] NOT NULL,
[ADDRESSUSEZIPPLUS4] [int] NOT NULL,
[ADDRFORMAT] [nvarchar](10) NOT NULL,
[BACENCODE_BR] [nvarchar](4) NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[ISIMMUTABLE] [int] NOT NULL,
[ISOCODE] [nchar](2) NOT NULL,
[TIMEZONE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_128014817_-305463479] PRIMARY KEY CLUSTERED 
(
[COUNTRYREGIONID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_ADDRESSUSEZIPPLUS4]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_ADDRESSUSEZIPPLUS4]  DEFAULT ((0)) FOR [ADDRESSUSEZIPPLUS4]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_ADDRFORMAT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_ADDRFORMAT]  DEFAULT ('') FOR [ADDRFORMAT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_BACENCODE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_BACENCODE_BR]  DEFAULT ('') FOR [BACENCODE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_ISIMMUTABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_ISIMMUTABLE]  DEFAULT ((0)) FOR [ISIMMUTABLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_ISOCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_ISOCODE]  DEFAULT ('') FOR [ISOCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGION_TIMEZONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGION_TIMEZONE]  DEFAULT ((0)) FOR [TIMEZONE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSCOUNTRYREGION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION](
[RECID] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[LONGNAME] [nvarchar](255) NOT NULL,
[SHORTNAME] [nvarchar](255) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_96499510_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_96499510_-1112445765] UNIQUE NONCLUSTERED 
(
[COUNTRYREGIONID] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_LONGNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_LONGNAME]  DEFAULT ('') FOR [LONGNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_SHORTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION_SHORTNAME]  DEFAULT ('') FOR [SHORTNAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSCOUNTY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSCOUNTY](
[RECID] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[COUNTYCODE_SP] [nchar](2) NOT NULL,
[COUNTYID] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[STATEID] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1242622437_-816487246] PRIMARY KEY CLUSTERED 
(
[COUNTRYREGIONID] ASC,
[STATEID] ASC,
[COUNTYID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTY_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTY_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTY_COUNTYCODE_SP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTY_COUNTYCODE_SP]  DEFAULT ('') FOR [COUNTYCODE_SP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTY_COUNTYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTY_COUNTYID]  DEFAULT ('') FOR [COUNTYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTY_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTY_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSCOUNTY_STATEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSCOUNTY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSCOUNTY_STATEID]  DEFAULT ('') FOR [STATEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSCOUNTY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSDISTRICT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSDISTRICT](
[RECID] [bigint] NOT NULL,
[CITY] [bigint] NOT NULL,
[COUNTRYREGIONID_RU] [nvarchar](10) NOT NULL,
[COUNTYID_RU] [nvarchar](10) NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[PROPERTIES_RU] [bigint] NOT NULL,
[STATEID_RU] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1765824537_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1765824537_246310896] UNIQUE NONCLUSTERED 
(
[NAME] ASC,
[CITY] ASC,
[COUNTRYREGIONID_RU] ASC,
[STATEID_RU] ASC,
[COUNTYID_RU] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_CITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_CITY]  DEFAULT ((0)) FOR [CITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_COUNTRYREGIONID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_COUNTRYREGIONID_RU]  DEFAULT ('') FOR [COUNTRYREGIONID_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_COUNTYID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_COUNTYID_RU]  DEFAULT ('') FOR [COUNTYID_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_PROPERTIES_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_PROPERTIES_RU]  DEFAULT ((0)) FOR [PROPERTIES_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSDISTRICT_STATEID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSDISTRICT] ADD  CONSTRAINT [DF_LOGISTICSADDRESSDISTRICT_STATEID_RU]  DEFAULT ('') FOR [STATEID_RU]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSDISTRICT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSFORMATHEADING]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSFORMATHEADING](
[RECID] [bigint] NOT NULL,
[ADDRFORMAT] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](100) NOT NULL,
[UPDATETOADDRESS] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_940083590_1389798729] PRIMARY KEY CLUSTERED 
(
[ADDRFORMAT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATHEADING_ADDRFORMAT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATHEADING] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATHEADING_ADDRFORMAT]  DEFAULT ('') FOR [ADDRFORMAT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATHEADING_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATHEADING] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATHEADING_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATHEADING_UPDATETOADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATHEADING] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATHEADING_UPDATETOADDRESS]  DEFAULT ((0)) FOR [UPDATETOADDRESS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSFORMATHEADING] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSFORMATLINES]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSFORMATLINES](
[RECID] [bigint] NOT NULL,
[ADDRFORMAT] [nvarchar](10) NOT NULL,
[DATAENTRYONLY] [int] NOT NULL,
[ELEMENT] [int] NOT NULL,
[INACTIVE] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[SEPARATOR] [nvarchar](10) NOT NULL,
[SEPARATORCRLF] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-900029417_819092615] PRIMARY KEY CLUSTERED 
(
[ADDRFORMAT] ASC,
[LINENUM] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-900029417_1662335864] UNIQUE NONCLUSTERED 
(
[ADDRFORMAT] ASC,
[ELEMENT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_ADDRFORMAT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_ADDRFORMAT]  DEFAULT ('') FOR [ADDRFORMAT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_DATAENTRYONLY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_DATAENTRYONLY]  DEFAULT ((0)) FOR [DATAENTRYONLY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_ELEMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_ELEMENT]  DEFAULT ((0)) FOR [ELEMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_INACTIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_INACTIVE]  DEFAULT ((0)) FOR [INACTIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_SEPARATOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_SEPARATOR]  DEFAULT ('') FOR [SEPARATOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSFORMATLINES_SEPARATORCRLF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSFORMATLINES] ADD  CONSTRAINT [DF_LOGISTICSADDRESSFORMATLINES_SEPARATORCRLF]  DEFAULT ((0)) FOR [SEPARATORCRLF]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSFORMATLINES] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSSCITY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSSCITY](
[RECID] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[COUNTYID] [nvarchar](10) NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[IBGECODE_BR] [nvarchar](7) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[STATEID] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1023594959_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSCITY_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSCITY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSCITY_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSCITY_COUNTYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSCITY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSCITY_COUNTYID]  DEFAULT ('') FOR [COUNTYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSCITY_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSCITY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSCITY_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSCITY_IBGECODE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSCITY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSCITY_IBGECODE_BR]  DEFAULT ('') FOR [IBGECODE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSCITY_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSCITY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSCITY_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSCITY_STATEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSCITY] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSCITY_STATEID]  DEFAULT ('') FOR [STATEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSSCITY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSSTATE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSSTATE](
[RECID] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[INTRASTATCODE] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[STATEID] [nvarchar](10) NOT NULL,
[TIMEZONE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-727715432_-971710904] PRIMARY KEY CLUSTERED 
(
[COUNTRYREGIONID] ASC,
[STATEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSTATE_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSTATE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSTATE_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSTATE_INTRASTATCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSTATE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSTATE_INTRASTATCODE]  DEFAULT ('') FOR [INTRASTATCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSTATE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSTATE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSTATE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSTATE_STATEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSTATE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSTATE_STATEID]  DEFAULT ('') FOR [STATEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSSTATE_TIMEZONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSSTATE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSSTATE_TIMEZONE]  DEFAULT ((0)) FOR [TIMEZONE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSSTATE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSADDRESSZIPCODE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSADDRESSZIPCODE](
[RECID] [bigint] NOT NULL,
[CITY] [nvarchar](60) NOT NULL,
[CITYALIAS] [nvarchar](30) NOT NULL,
[CITYRECID] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[COUNTY] [nvarchar](10) NOT NULL,
[DISTRICT] [bigint] NOT NULL,
[DISTRICTNAME] [nvarchar](60) NOT NULL,
[EVENODD] [int] NOT NULL,
[FROMNUM] [int] NOT NULL,
[STATE] [nvarchar](10) NOT NULL,
[STREETNAME] [nvarchar](60) NOT NULL,
[TIMEZONE] [int] NOT NULL,
[TONUM] [int] NOT NULL,
[ZIPCODE] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_966996751_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_CITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_CITY]  DEFAULT ('') FOR [CITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_CITYALIAS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_CITYALIAS]  DEFAULT ('') FOR [CITYALIAS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_CITYRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_CITYRECID]  DEFAULT ((0)) FOR [CITYRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_COUNTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_COUNTY]  DEFAULT ('') FOR [COUNTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_DISTRICT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_DISTRICT]  DEFAULT ((0)) FOR [DISTRICT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_DISTRICTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_DISTRICTNAME]  DEFAULT ('') FOR [DISTRICTNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_EVENODD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_EVENODD]  DEFAULT ((0)) FOR [EVENODD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_FROMNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_FROMNUM]  DEFAULT ((0)) FOR [FROMNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_STATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_STATE]  DEFAULT ('') FOR [STATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_STREETNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_STREETNAME]  DEFAULT ('') FOR [STREETNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_TIMEZONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_TIMEZONE]  DEFAULT ((0)) FOR [TIMEZONE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_TONUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_TONUM]  DEFAULT ((0)) FOR [TONUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSADDRESSZIPCODE_ZIPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSADDRESSZIPCODE] ADD  CONSTRAINT [DF_LOGISTICSADDRESSZIPCODE_ZIPCODE]  DEFAULT ('') FOR [ZIPCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSADDRESSZIPCODE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSELECTRONICADDRESS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSELECTRONICADDRESS](
[RECID] [bigint] NOT NULL,
[COUNTRYREGIONCODE] [nvarchar](5) NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[ISINSTANTMESSAGE] [int] NOT NULL,
[ISMOBILEPHONE] [int] NOT NULL,
[ISPRIMARY] [int] NOT NULL,
[ISPRIVATE] [int] NOT NULL,
[LOCATION] [bigint] NOT NULL,
[LOCATOR] [nvarchar](255) NOT NULL,
[LOCATOREXTENSION] [nvarchar](10) NOT NULL,
[TYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1137359931_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_COUNTRYREGIONCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_COUNTRYREGIONCODE]  DEFAULT ('') FOR [COUNTRYREGIONCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_ISINSTANTMESSAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_ISINSTANTMESSAGE]  DEFAULT ((0)) FOR [ISINSTANTMESSAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_ISMOBILEPHONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_ISMOBILEPHONE]  DEFAULT ((0)) FOR [ISMOBILEPHONE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_ISPRIMARY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_ISPRIMARY]  DEFAULT ((0)) FOR [ISPRIMARY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_ISPRIVATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_ISPRIVATE]  DEFAULT ((0)) FOR [ISPRIVATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_LOCATION]  DEFAULT ((0)) FOR [LOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_LOCATOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_LOCATOR]  DEFAULT ('') FOR [LOCATOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_LOCATOREXTENSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_LOCATOREXTENSION]  DEFAULT ('') FOR [LOCATOREXTENSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSELECTRONICADDRESS_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSELECTRONICADDRESS] ADD  CONSTRAINT [DF_LOGISTICSELECTRONICADDRESS_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSELECTRONICADDRESS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSLOCATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSLOCATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[DUNSNUMBERRECID] [bigint] NOT NULL,
[ISPOSTALADDRESS] [int] NOT NULL,
[LOCATIONID] [nvarchar](30) NOT NULL,
[PARENTLOCATION] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1358324402_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1358324402_760607746] UNIQUE NONCLUSTERED 
(
[LOCATIONID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_DUNSNUMBERRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_DUNSNUMBERRECID]  DEFAULT ((0)) FOR [DUNSNUMBERRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_ISPOSTALADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_ISPOSTALADDRESS]  DEFAULT ((0)) FOR [ISPOSTALADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_LOCATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_LOCATIONID]  DEFAULT ('') FOR [LOCATIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_PARENTLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_PARENTLOCATION]  DEFAULT ((0)) FOR [PARENTLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATION_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATION_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSLOCATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSLOCATIONEXT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSLOCATIONEXT](
[RECID] [bigint] NOT NULL,
[LOCATION] [bigint] NOT NULL,
[SALESCALENDARID] [nvarchar](10) NOT NULL,
[TAXGROUP] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-45831765_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-45831765_167473448] UNIQUE NONCLUSTERED 
(
[LOCATION] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONEXT_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONEXT] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONEXT_LOCATION]  DEFAULT ((0)) FOR [LOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONEXT_SALESCALENDARID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONEXT] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONEXT_SALESCALENDARID]  DEFAULT ('') FOR [SALESCALENDARID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONEXT_TAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONEXT] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONEXT_TAXGROUP]  DEFAULT ('') FOR [TAXGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSLOCATIONEXT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSLOCATIONROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSLOCATIONROLE](
[RECID] [bigint] NOT NULL,
[ISCONTACTINFO] [int] NOT NULL,
[ISPOSTALADDRESS] [int] NOT NULL,
[NAME] [nvarchar](40) NOT NULL,
[TYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_517951034_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_517951034_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLE_ISCONTACTINFO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLE] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLE_ISCONTACTINFO]  DEFAULT ((0)) FOR [ISCONTACTINFO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLE_ISPOSTALADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLE] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLE_ISPOSTALADDRESS]  DEFAULT ((0)) FOR [ISPOSTALADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLE] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLE_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLE] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLE_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSLOCATIONROLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSLOCATIONROLETRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSLOCATIONROLETRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[LOCATIONROLE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_32160965_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_32160965_619597902] UNIQUE NONCLUSTERED 
(
[LOCATIONROLE] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLETRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLETRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLETRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLETRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLETRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLETRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSLOCATIONROLETRANSLATION_LOCATIONROLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSLOCATIONROLETRANSLATION] ADD  CONSTRAINT [DF_LOGISTICSLOCATIONROLETRANSLATION_LOCATIONROLE]  DEFAULT ((0)) FOR [LOCATIONROLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSLOCATIONROLETRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[LOGISTICSPOSTALADDRESS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[LOGISTICSPOSTALADDRESS](
[RECID] [bigint] NOT NULL,
[ADDRESS] [nvarchar](250) NOT NULL,
[BUILDINGCOMPLIMENT] [nvarchar](60) NOT NULL,
[CITY] [nvarchar](60) NOT NULL,
[CITYRECID] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[COUNTY] [nvarchar](10) NOT NULL,
[DISTRICT] [bigint] NOT NULL,
[DISTRICTNAME] [nvarchar](60) NOT NULL,
[ISPRIVATE] [int] NOT NULL,
[LATITUDE] [numeric](32, 16) NOT NULL,
[LOCATION] [bigint] NOT NULL,
[LONGITUDE] [numeric](32, 16) NOT NULL,
[POSTBOX] [nvarchar](20) NOT NULL,
[STATE] [nvarchar](10) NOT NULL,
[STREET] [nvarchar](250) NOT NULL,
[STREETNUMBER] [nvarchar](20) NOT NULL,
[TIMEZONE] [int] NOT NULL,
[VALIDFROM] [datetime] NOT NULL,
[VALIDFROMTZID] [int] NOT NULL,
[VALIDTO] [datetime] NOT NULL,
[VALIDTOTZID] [int] NOT NULL,
[ZIPCODE] [nvarchar](10) NOT NULL,
[ZIPCODERECID] [bigint] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_621354382_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_621354382_2047046459] UNIQUE NONCLUSTERED 
(
[LOCATION] ASC,
[VALIDFROM] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_ADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_ADDRESS]  DEFAULT ('') FOR [ADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_BUILDINGCOMPLIMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_BUILDINGCOMPLIMENT]  DEFAULT ('') FOR [BUILDINGCOMPLIMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_CITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_CITY]  DEFAULT ('') FOR [CITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_CITYRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_CITYRECID]  DEFAULT ((0)) FOR [CITYRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_COUNTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_COUNTY]  DEFAULT ('') FOR [COUNTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_DISTRICT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_DISTRICT]  DEFAULT ((0)) FOR [DISTRICT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_DISTRICTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_DISTRICTNAME]  DEFAULT ('') FOR [DISTRICTNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_ISPRIVATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_ISPRIVATE]  DEFAULT ((0)) FOR [ISPRIVATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_LATITUDE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_LATITUDE]  DEFAULT ((0)) FOR [LATITUDE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_LOCATION]  DEFAULT ((0)) FOR [LOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_LONGITUDE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_LONGITUDE]  DEFAULT ((0)) FOR [LONGITUDE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_POSTBOX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_POSTBOX]  DEFAULT ('') FOR [POSTBOX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_STATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_STATE]  DEFAULT ('') FOR [STATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_STREET]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_STREET]  DEFAULT ('') FOR [STREET]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_STREETNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_STREETNUMBER]  DEFAULT ('') FOR [STREETNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_TIMEZONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_TIMEZONE]  DEFAULT ((0)) FOR [TIMEZONE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_VALIDFROM]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_VALIDFROMTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_VALIDFROMTZID]  DEFAULT ((37001)) FOR [VALIDFROMTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_VALIDTO]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_VALIDTOTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_VALIDTOTZID]  DEFAULT ((37001)) FOR [VALIDTOTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_ZIPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_ZIPCODE]  DEFAULT ('') FOR [ZIPCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_ZIPCODERECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_ZIPCODERECID]  DEFAULT ((0)) FOR [ZIPCODERECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_LOGISTICSPOSTALADDRESS_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[LOGISTICSPOSTALADDRESS] ADD  CONSTRAINT [DF_LOGISTICSPOSTALADDRESS_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[LOGISTICSPOSTALADDRESS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[MARKUPAUTOLINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[MARKUPAUTOLINE](
[RECID] [bigint] NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[CUSTOMSASSESSABLEVALUE_IN] [int] NOT NULL,
[FROMAMOUNT] [numeric](32, 16) NOT NULL,
[KEEP] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[MARKUPCATEGORY] [int] NOT NULL,
[MARKUPCODE] [nvarchar](10) NOT NULL,
[MARKUPCURRENCYCODE] [nvarchar](3) NOT NULL,
[MODULECATEGORY] [int] NOT NULL,
[MODULETYPE] [int] NOT NULL,
[NOTIONALCHARGES_IN] [int] NOT NULL,
[NOTIONALPCT_IN] [numeric](32, 16) NOT NULL,
[TABLERECID] [bigint] NOT NULL,
[TABLETABLEID] [int] NOT NULL,
[TAXGROUP] [nvarchar](10) NOT NULL,
[TAXITEMGROUP] [nvarchar](10) NOT NULL,
[TOAMOUNT] [numeric](32, 16) NOT NULL,
[TXT] [nvarchar](60) NOT NULL,
[VALUE] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1293693211_-1942181553] PRIMARY KEY CLUSTERED 
(
[TABLERECID] ASC,
[TABLETABLEID] ASC,
[LINENUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_CUSTOMSASSESSABLEVALUE_IN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_CUSTOMSASSESSABLEVALUE_IN]  DEFAULT ((0)) FOR [CUSTOMSASSESSABLEVALUE_IN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_FROMAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_FROMAMOUNT]  DEFAULT ((0)) FOR [FROMAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_KEEP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_KEEP]  DEFAULT ((0)) FOR [KEEP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_MARKUPCATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_MARKUPCATEGORY]  DEFAULT ((0)) FOR [MARKUPCATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_MARKUPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_MARKUPCODE]  DEFAULT ('') FOR [MARKUPCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_MARKUPCURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_MARKUPCURRENCYCODE]  DEFAULT ('') FOR [MARKUPCURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_MODULECATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_MODULECATEGORY]  DEFAULT ((0)) FOR [MODULECATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_MODULETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_MODULETYPE]  DEFAULT ((0)) FOR [MODULETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_NOTIONALCHARGES_IN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_NOTIONALCHARGES_IN]  DEFAULT ((0)) FOR [NOTIONALCHARGES_IN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_NOTIONALPCT_IN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_NOTIONALPCT_IN]  DEFAULT ((0)) FOR [NOTIONALPCT_IN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_TABLERECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_TABLERECID]  DEFAULT ((0)) FOR [TABLERECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_TABLETABLEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_TABLETABLEID]  DEFAULT ((0)) FOR [TABLETABLEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_TAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_TAXGROUP]  DEFAULT ('') FOR [TAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_TAXITEMGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_TAXITEMGROUP]  DEFAULT ('') FOR [TAXITEMGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_TOAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_TOAMOUNT]  DEFAULT ((0)) FOR [TOAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_TXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_TXT]  DEFAULT ('') FOR [TXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOLINE_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOLINE] ADD  CONSTRAINT [DF_MARKUPAUTOLINE_VALUE]  DEFAULT ((0)) FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[MARKUPAUTOLINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[MARKUPAUTOTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[MARKUPAUTOTABLE](
[RECID] [bigint] NOT NULL,
[ACCOUNTCODE] [int] NOT NULL,
[ACCOUNTRELATION] [nvarchar](20) NOT NULL,
[DLVMODECODE] [int] NOT NULL,
[DLVMODERELATION] [nvarchar](20) NOT NULL,
[ITEMCODE] [int] NOT NULL,
[ITEMRELATION] [nvarchar](20) NOT NULL,
[MARKUPRETURN] [int] NOT NULL,
[MODULECATEGORY] [int] NOT NULL,
[MODULETYPE] [int] NOT NULL,
[RETAILCONCESSIONFEE] [int] NOT NULL,
[RETURNRELATION] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_366724785_-1598920379] PRIMARY KEY CLUSTERED 
(
[MODULECATEGORY] ASC,
[MODULETYPE] ASC,
[ITEMCODE] ASC,
[ITEMRELATION] ASC,
[ACCOUNTCODE] ASC,
[ACCOUNTRELATION] ASC,
[MARKUPRETURN] ASC,
[RETURNRELATION] ASC,
[RETAILCONCESSIONFEE] ASC,
[DLVMODECODE] ASC,
[DLVMODERELATION] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_ACCOUNTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_ACCOUNTCODE]  DEFAULT ((0)) FOR [ACCOUNTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_ACCOUNTRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_ACCOUNTRELATION]  DEFAULT ('') FOR [ACCOUNTRELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_DLVMODECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_DLVMODECODE]  DEFAULT ((0)) FOR [DLVMODECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_DLVMODERELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_DLVMODERELATION]  DEFAULT ('') FOR [DLVMODERELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_ITEMCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_ITEMCODE]  DEFAULT ((0)) FOR [ITEMCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_ITEMRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_ITEMRELATION]  DEFAULT ('') FOR [ITEMRELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_MARKUPRETURN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_MARKUPRETURN]  DEFAULT ((0)) FOR [MARKUPRETURN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_MODULECATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_MODULECATEGORY]  DEFAULT ((0)) FOR [MODULECATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_MODULETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_MODULETYPE]  DEFAULT ((0)) FOR [MODULETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_RETAILCONCESSIONFEE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_RETAILCONCESSIONFEE]  DEFAULT ((0)) FOR [RETAILCONCESSIONFEE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPAUTOTABLE_RETURNRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPAUTOTABLE] ADD  CONSTRAINT [DF_MARKUPAUTOTABLE_RETURNRELATION]  DEFAULT ('') FOR [RETURNRELATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[MARKUPAUTOTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[MARKUPTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[MARKUPTABLE](
[RECID] [bigint] NOT NULL,
[CUSTOMERLEDGERDIMENSION] [bigint] NOT NULL,
[CUSTPOSTING] [int] NOT NULL,
[CUSTTYPE] [int] NOT NULL,
[INTRASTAT_FI] [int] NOT NULL,
[ISLETTEROFCREDIT_SA] [int] NOT NULL,
[MARKUPCODE] [nvarchar](10) NOT NULL,
[MAXAMOUNT] [numeric](32, 16) NOT NULL,
[MODULETYPE] [int] NOT NULL,
[RETAILCONCESSIONFEE] [int] NOT NULL,
[TAXITEMGROUP] [nvarchar](10) NOT NULL,
[TXT] [nvarchar](60) NOT NULL,
[USEINMATCHING] [int] NOT NULL,
[VENDORLEDGERDIMENSION] [bigint] NOT NULL,
[VENDPOSTING] [int] NOT NULL,
[VENDTYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1530831318_-1628860358] PRIMARY KEY CLUSTERED 
(
[MODULETYPE] ASC,
[MARKUPCODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_CUSTOMERLEDGERDIMENSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_CUSTOMERLEDGERDIMENSION]  DEFAULT ((0)) FOR [CUSTOMERLEDGERDIMENSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_CUSTPOSTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_CUSTPOSTING]  DEFAULT ((0)) FOR [CUSTPOSTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_CUSTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_CUSTTYPE]  DEFAULT ((0)) FOR [CUSTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_INTRASTAT_FI]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_INTRASTAT_FI]  DEFAULT ((0)) FOR [INTRASTAT_FI]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_ISLETTEROFCREDIT_SA]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_ISLETTEROFCREDIT_SA]  DEFAULT ((0)) FOR [ISLETTEROFCREDIT_SA]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_MARKUPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_MARKUPCODE]  DEFAULT ('') FOR [MARKUPCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_MAXAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_MAXAMOUNT]  DEFAULT ((0)) FOR [MAXAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_MODULETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_MODULETYPE]  DEFAULT ((0)) FOR [MODULETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_RETAILCONCESSIONFEE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_RETAILCONCESSIONFEE]  DEFAULT ((0)) FOR [RETAILCONCESSIONFEE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_TAXITEMGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_TAXITEMGROUP]  DEFAULT ('') FOR [TAXITEMGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_TXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_TXT]  DEFAULT ('') FOR [TXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_USEINMATCHING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_USEINMATCHING]  DEFAULT ((0)) FOR [USEINMATCHING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_VENDORLEDGERDIMENSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_VENDORLEDGERDIMENSION]  DEFAULT ((0)) FOR [VENDORLEDGERDIMENSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_VENDPOSTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_VENDPOSTING]  DEFAULT ((0)) FOR [VENDPOSTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_MARKUPTABLE_VENDTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[MARKUPTABLE] ADD  CONSTRAINT [DF_MARKUPTABLE_VENDTYPE]  DEFAULT ((0)) FOR [VENDTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[MARKUPTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH](
[RECID] [bigint] NOT NULL,
[ANCESTORORGANIZATION] [bigint] NOT NULL,
[DISTANCE] [int] NOT NULL,
[OMHIERARCHYTYPE] [bigint] NOT NULL,
[ORGANIZATION] [bigint] NOT NULL,
[VALIDFROM] [datetime] NOT NULL,
[VALIDFROMTZID] [int] NOT NULL,
[VALIDTO] [datetime] NOT NULL,
[VALIDTOTZID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-76086348_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-76086348_-916295028] UNIQUE NONCLUSTERED 
(
[OMHIERARCHYTYPE] ASC,
[DISTANCE] ASC,
[ORGANIZATION] ASC,
[VALIDFROM] ASC,
[VALIDTO] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_ANCESTORORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_ANCESTORORGANIZATION]  DEFAULT ((0)) FOR [ANCESTORORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_DISTANCE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_DISTANCE]  DEFAULT ((0)) FOR [DISTANCE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_OMHIERARCHYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_OMHIERARCHYTYPE]  DEFAULT ((0)) FOR [OMHIERARCHYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_ORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_ORGANIZATION]  DEFAULT ((0)) FOR [ORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDFROM]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDFROMTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDFROMTZID]  DEFAULT ((37001)) FOR [VALIDFROMTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDTO]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDTOTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] ADD  CONSTRAINT [DF_OMEXPLODEDORGANIZATIONSECURITYGRAPH_VALIDTOTZID]  DEFAULT ((37001)) FOR [VALIDTOTZID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[OMEXPLODEDORGANIZATIONSECURITYGRAPH] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[OMHIERARCHYPURPOSE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[OMHIERARCHYPURPOSE](
[RECID] [bigint] NOT NULL,
[HIERARCHYPURPOSE] [int] NOT NULL,
[HIERARCHYTYPE] [bigint] NOT NULL,
[ISDEFAULT] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_269376623_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_269376623_-1726555760] UNIQUE NONCLUSTERED 
(
[HIERARCHYPURPOSE] ASC,
[HIERARCHYTYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMHIERARCHYPURPOSE_HIERARCHYPURPOSE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMHIERARCHYPURPOSE] ADD  CONSTRAINT [DF_OMHIERARCHYPURPOSE_HIERARCHYPURPOSE]  DEFAULT ((0)) FOR [HIERARCHYPURPOSE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMHIERARCHYPURPOSE_HIERARCHYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMHIERARCHYPURPOSE] ADD  CONSTRAINT [DF_OMHIERARCHYPURPOSE_HIERARCHYTYPE]  DEFAULT ((0)) FOR [HIERARCHYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMHIERARCHYPURPOSE_ISDEFAULT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMHIERARCHYPURPOSE] ADD  CONSTRAINT [DF_OMHIERARCHYPURPOSE_ISDEFAULT]  DEFAULT ((0)) FOR [ISDEFAULT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[OMHIERARCHYPURPOSE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[OMINTERNALORGANIZATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[OMINTERNALORGANIZATION](
[RECID] [bigint] NOT NULL,
[ORGANIZATIONTYPE] [int] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1760313484_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[OMINTERNALORGANIZATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[OMOPERATINGUNIT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[OMOPERATINGUNIT](
[RECID] [bigint] NOT NULL,
[HCMWORKER] [bigint] NULL,
[OMOPERATINGUNITNUMBER] [nvarchar](8) NOT NULL,
[OMOPERATINGUNITTYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-901362831_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-901362831_1785045346] UNIQUE NONCLUSTERED 
(
[OMOPERATINGUNITNUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMOPERATINGUNIT_OMOPERATINGUNITNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMOPERATINGUNIT] ADD  CONSTRAINT [DF_OMOPERATINGUNIT_OMOPERATINGUNITNUMBER]  DEFAULT ('') FOR [OMOPERATINGUNITNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_OMOPERATINGUNIT_OMOPERATINGUNITTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[OMOPERATINGUNIT] ADD  CONSTRAINT [DF_OMOPERATINGUNIT_OMOPERATINGUNITTYPE]  DEFAULT ((0)) FOR [OMOPERATINGUNITTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[OMOPERATINGUNIT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[PLFISCALTAXTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[PLFISCALTAXTABLE](
[RECID] [bigint] NOT NULL,
[FISCALPRINTERCODE] [nvarchar](20) NOT NULL,
[FISCALTAXCODE] [int] NOT NULL,
[TAXCODE] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1142401777_-1211354216] PRIMARY KEY CLUSTERED 
(
[TAXCODE] ASC,
[FISCALPRINTERCODE] ASC,
[FISCALTAXCODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PLFISCALTAXTABLE_FISCALPRINTERCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PLFISCALTAXTABLE] ADD  CONSTRAINT [DF_PLFISCALTAXTABLE_FISCALPRINTERCODE]  DEFAULT ('') FOR [FISCALPRINTERCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PLFISCALTAXTABLE_FISCALTAXCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PLFISCALTAXTABLE] ADD  CONSTRAINT [DF_PLFISCALTAXTABLE_FISCALTAXCODE]  DEFAULT ((0)) FOR [FISCALTAXCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PLFISCALTAXTABLE_TAXCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PLFISCALTAXTABLE] ADD  CONSTRAINT [DF_PLFISCALTAXTABLE_TAXCODE]  DEFAULT ('') FOR [TAXCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[PLFISCALTAXTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[PRICEDISCGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[PRICEDISCGROUP](
[RECID] [bigint] NOT NULL,
[GROUPID] [nvarchar](10) NOT NULL,
[MODULE] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[TYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1621373531_2009434683] PRIMARY KEY CLUSTERED 
(
[MODULE] ASC,
[TYPE] ASC,
[GROUPID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCGROUP_GROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCGROUP] ADD  CONSTRAINT [DF_PRICEDISCGROUP_GROUPID]  DEFAULT ('') FOR [GROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCGROUP_MODULE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCGROUP] ADD  CONSTRAINT [DF_PRICEDISCGROUP_MODULE]  DEFAULT ((0)) FOR [MODULE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCGROUP_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCGROUP] ADD  CONSTRAINT [DF_PRICEDISCGROUP_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCGROUP_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCGROUP] ADD  CONSTRAINT [DF_PRICEDISCGROUP_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[PRICEDISCGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[PRICEDISCTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[PRICEDISCTABLE](
[RECID] [bigint] NOT NULL,
[ACCOUNTCODE] [int] NOT NULL,
[ACCOUNTRELATION] [nvarchar](20) NOT NULL,
[AGREEMENT] [nvarchar](10) NOT NULL,
[AGREEMENTHEADEREXT_RU] [bigint] NOT NULL,
[ALLOCATEMARKUP] [int] NOT NULL,
[AMOUNT] [numeric](32, 16) NOT NULL,
[CALENDARDAYS] [int] NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[DELIVERYTIME] [int] NOT NULL,
[FROMDATE] [date] NOT NULL,
[GENERICCURRENCY] [int] NOT NULL,
[INVENTDIMID] [nvarchar](20) NOT NULL,
[ITEMCODE] [int] NOT NULL,
[ITEMRELATION] [nvarchar](20) NOT NULL,
[MARKUP] [numeric](32, 16) NOT NULL,
[MAXIMUMRETAILPRICE_IN] [numeric](32, 16) NOT NULL,
[MODULE] [int] NOT NULL,
[PERCENT1] [numeric](32, 16) NOT NULL,
[PERCENT2] [numeric](32, 16) NOT NULL,
[PRICEUNIT] [numeric](32, 16) NOT NULL,
[QUANTITYAMOUNTFROM] [numeric](32, 16) NOT NULL,
[QUANTITYAMOUNTTO] [numeric](32, 16) NOT NULL,
[RELATION] [int] NOT NULL,
[SEARCHAGAIN] [int] NOT NULL,
[TODATE] [date] NOT NULL,
[UNITID] [nvarchar](10) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_137462222_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_137462222_1904821809] UNIQUE NONCLUSTERED 
(
[RELATION] ASC,
[ITEMCODE] ASC,
[ITEMRELATION] ASC,
[ACCOUNTCODE] ASC,
[ACCOUNTRELATION] ASC,
[CURRENCY] ASC,
[INVENTDIMID] ASC,
[UNITID] ASC,
[QUANTITYAMOUNTFROM] ASC,
[RECID] ASC,
[FROMDATE] ASC,
[AGREEMENTHEADEREXT_RU] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_ACCOUNTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_ACCOUNTCODE]  DEFAULT ((0)) FOR [ACCOUNTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_ACCOUNTRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_ACCOUNTRELATION]  DEFAULT ('') FOR [ACCOUNTRELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_AGREEMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_AGREEMENT]  DEFAULT ('') FOR [AGREEMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_AGREEMENTHEADEREXT_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_AGREEMENTHEADEREXT_RU]  DEFAULT ((0)) FOR [AGREEMENTHEADEREXT_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_ALLOCATEMARKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_ALLOCATEMARKUP]  DEFAULT ((0)) FOR [ALLOCATEMARKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_CALENDARDAYS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_CALENDARDAYS]  DEFAULT ((0)) FOR [CALENDARDAYS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_DELIVERYTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_DELIVERYTIME]  DEFAULT ((0)) FOR [DELIVERYTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_FROMDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_FROMDATE]  DEFAULT ('1900-01-01') FOR [FROMDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_GENERICCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_GENERICCURRENCY]  DEFAULT ((0)) FOR [GENERICCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_INVENTDIMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_INVENTDIMID]  DEFAULT ('') FOR [INVENTDIMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_ITEMCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_ITEMCODE]  DEFAULT ((0)) FOR [ITEMCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_ITEMRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_ITEMRELATION]  DEFAULT ('') FOR [ITEMRELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_MARKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_MARKUP]  DEFAULT ((0)) FOR [MARKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_MAXIMUMRETAILPRICE_IN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_MAXIMUMRETAILPRICE_IN]  DEFAULT ((0)) FOR [MAXIMUMRETAILPRICE_IN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_MODULE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_MODULE]  DEFAULT ((0)) FOR [MODULE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_PERCENT1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_PERCENT1]  DEFAULT ((0)) FOR [PERCENT1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_PERCENT2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_PERCENT2]  DEFAULT ((0)) FOR [PERCENT2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_PRICEUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_PRICEUNIT]  DEFAULT ((0)) FOR [PRICEUNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_QUANTITYAMOUNTFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_QUANTITYAMOUNTFROM]  DEFAULT ((0)) FOR [QUANTITYAMOUNTFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_QUANTITYAMOUNTTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_QUANTITYAMOUNTTO]  DEFAULT ((0)) FOR [QUANTITYAMOUNTTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_RELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_RELATION]  DEFAULT ((0)) FOR [RELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_SEARCHAGAIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_SEARCHAGAIN]  DEFAULT ((0)) FOR [SEARCHAGAIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_TODATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_TODATE]  DEFAULT ('1900-01-01') FOR [TODATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_UNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_UNITID]  DEFAULT ('') FOR [UNITID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEDISCTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEDISCTABLE] ADD  CONSTRAINT [DF_PRICEDISCTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[PRICEDISCTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[PRICEPARAMETERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[PRICEPARAMETERS](
[RECID] [bigint] NOT NULL,
[KEY] [int] NOT NULL,
[PURCHENDACCOUNTALL] [int] NOT NULL,
[PURCHENDALLALL] [int] NOT NULL,
[PURCHENDGROUPALL] [int] NOT NULL,
[PURCHLINEACCOUNTALL] [int] NOT NULL,
[PURCHLINEACCOUNTGROUP] [int] NOT NULL,
[PURCHLINEACCOUNTITEM] [int] NOT NULL,
[PURCHLINEALLALL] [int] NOT NULL,
[PURCHLINEALLGROUP] [int] NOT NULL,
[PURCHLINEALLITEM] [int] NOT NULL,
[PURCHLINEGROUPALL] [int] NOT NULL,
[PURCHLINEGROUPGROUP] [int] NOT NULL,
[PURCHLINEGROUPITEM] [int] NOT NULL,
[PURCHMULTILNACCOUNTALL] [int] NOT NULL,
[PURCHMULTILNACCOUNTGROUP] [int] NOT NULL,
[PURCHMULTILNALLALL] [int] NOT NULL,
[PURCHMULTILNALLGROUP] [int] NOT NULL,
[PURCHMULTILNGROUPALL] [int] NOT NULL,
[PURCHMULTILNGROUPGROUP] [int] NOT NULL,
[PURCHPRICEACCOUNTITEM] [int] NOT NULL,
[PURCHPRICEALLITEM] [int] NOT NULL,
[PURCHPRICEGROUPITEM] [int] NOT NULL,
[SALESENDACCOUNTALL] [int] NOT NULL,
[SALESENDALLALL] [int] NOT NULL,
[SALESENDGROUPALL] [int] NOT NULL,
[SALESLINEACCOUNTALL] [int] NOT NULL,
[SALESLINEACCOUNTGROUP] [int] NOT NULL,
[SALESLINEACCOUNTITEM] [int] NOT NULL,
[SALESLINEALLALL] [int] NOT NULL,
[SALESLINEALLGROUP] [int] NOT NULL,
[SALESLINEALLITEM] [int] NOT NULL,
[SALESLINEGROUPALL] [int] NOT NULL,
[SALESLINEGROUPGROUP] [int] NOT NULL,
[SALESLINEGROUPITEM] [int] NOT NULL,
[SALESMULTILNACCOUNTALL] [int] NOT NULL,
[SALESMULTILNACCOUNTGROUP] [int] NOT NULL,
[SALESMULTILNALLALL] [int] NOT NULL,
[SALESMULTILNALLGROUP] [int] NOT NULL,
[SALESMULTILNGROUPALL] [int] NOT NULL,
[SALESMULTILNGROUPGROUP] [int] NOT NULL,
[SALESPRICEACCOUNTITEM] [int] NOT NULL,
[SALESPRICEALLITEM] [int] NOT NULL,
[SALESPRICEGROUPITEM] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_327828059_-1273337705] PRIMARY KEY CLUSTERED 
(
[KEY] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_KEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_KEY]  DEFAULT ((0)) FOR [KEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHENDACCOUNTALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHENDACCOUNTALL]  DEFAULT ((0)) FOR [PURCHENDACCOUNTALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHENDALLALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHENDALLALL]  DEFAULT ((0)) FOR [PURCHENDALLALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHENDGROUPALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHENDGROUPALL]  DEFAULT ((0)) FOR [PURCHENDGROUPALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEACCOUNTALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEACCOUNTALL]  DEFAULT ((0)) FOR [PURCHLINEACCOUNTALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEACCOUNTGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEACCOUNTGROUP]  DEFAULT ((0)) FOR [PURCHLINEACCOUNTGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEACCOUNTITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEACCOUNTITEM]  DEFAULT ((0)) FOR [PURCHLINEACCOUNTITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEALLALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEALLALL]  DEFAULT ((0)) FOR [PURCHLINEALLALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEALLGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEALLGROUP]  DEFAULT ((0)) FOR [PURCHLINEALLGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEALLITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEALLITEM]  DEFAULT ((0)) FOR [PURCHLINEALLITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEGROUPALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEGROUPALL]  DEFAULT ((0)) FOR [PURCHLINEGROUPALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEGROUPGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEGROUPGROUP]  DEFAULT ((0)) FOR [PURCHLINEGROUPGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHLINEGROUPITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHLINEGROUPITEM]  DEFAULT ((0)) FOR [PURCHLINEGROUPITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHMULTILNACCOUNTALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHMULTILNACCOUNTALL]  DEFAULT ((0)) FOR [PURCHMULTILNACCOUNTALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHMULTILNACCOUNTGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHMULTILNACCOUNTGROUP]  DEFAULT ((0)) FOR [PURCHMULTILNACCOUNTGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHMULTILNALLALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHMULTILNALLALL]  DEFAULT ((0)) FOR [PURCHMULTILNALLALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHMULTILNALLGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHMULTILNALLGROUP]  DEFAULT ((0)) FOR [PURCHMULTILNALLGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHMULTILNGROUPALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHMULTILNGROUPALL]  DEFAULT ((0)) FOR [PURCHMULTILNGROUPALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHMULTILNGROUPGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHMULTILNGROUPGROUP]  DEFAULT ((0)) FOR [PURCHMULTILNGROUPGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHPRICEACCOUNTITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHPRICEACCOUNTITEM]  DEFAULT ((0)) FOR [PURCHPRICEACCOUNTITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHPRICEALLITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHPRICEALLITEM]  DEFAULT ((0)) FOR [PURCHPRICEALLITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_PURCHPRICEGROUPITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_PURCHPRICEGROUPITEM]  DEFAULT ((0)) FOR [PURCHPRICEGROUPITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESENDACCOUNTALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESENDACCOUNTALL]  DEFAULT ((0)) FOR [SALESENDACCOUNTALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESENDALLALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESENDALLALL]  DEFAULT ((0)) FOR [SALESENDALLALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESENDGROUPALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESENDGROUPALL]  DEFAULT ((0)) FOR [SALESENDGROUPALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEACCOUNTALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEACCOUNTALL]  DEFAULT ((0)) FOR [SALESLINEACCOUNTALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEACCOUNTGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEACCOUNTGROUP]  DEFAULT ((0)) FOR [SALESLINEACCOUNTGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEACCOUNTITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEACCOUNTITEM]  DEFAULT ((0)) FOR [SALESLINEACCOUNTITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEALLALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEALLALL]  DEFAULT ((0)) FOR [SALESLINEALLALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEALLGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEALLGROUP]  DEFAULT ((0)) FOR [SALESLINEALLGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEALLITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEALLITEM]  DEFAULT ((0)) FOR [SALESLINEALLITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEGROUPALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEGROUPALL]  DEFAULT ((0)) FOR [SALESLINEGROUPALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEGROUPGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEGROUPGROUP]  DEFAULT ((0)) FOR [SALESLINEGROUPGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESLINEGROUPITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESLINEGROUPITEM]  DEFAULT ((0)) FOR [SALESLINEGROUPITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESMULTILNACCOUNTALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESMULTILNACCOUNTALL]  DEFAULT ((0)) FOR [SALESMULTILNACCOUNTALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESMULTILNACCOUNTGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESMULTILNACCOUNTGROUP]  DEFAULT ((0)) FOR [SALESMULTILNACCOUNTGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESMULTILNALLALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESMULTILNALLALL]  DEFAULT ((0)) FOR [SALESMULTILNALLALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESMULTILNALLGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESMULTILNALLGROUP]  DEFAULT ((0)) FOR [SALESMULTILNALLGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESMULTILNGROUPALL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESMULTILNGROUPALL]  DEFAULT ((0)) FOR [SALESMULTILNGROUPALL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESMULTILNGROUPGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESMULTILNGROUPGROUP]  DEFAULT ((0)) FOR [SALESMULTILNGROUPGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESPRICEACCOUNTITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESPRICEACCOUNTITEM]  DEFAULT ((0)) FOR [SALESPRICEACCOUNTITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESPRICEALLITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESPRICEALLITEM]  DEFAULT ((0)) FOR [SALESPRICEALLITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_PRICEPARAMETERS_SALESPRICEGROUPITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[PRICEPARAMETERS] ADD  CONSTRAINT [DF_PRICEPARAMETERS_SALESPRICEGROUPITEM]  DEFAULT ((0)) FOR [SALESPRICEGROUPITEM]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[PRICEPARAMETERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILAFFILIATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILAFFILIATION](
[RECID] [bigint] NOT NULL,
[AFFILIATIONTYPE] [int] NOT NULL,
[NAME] [nvarchar](64) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2069845833_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2069845833_-1405435399] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATION_AFFILIATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATION] ADD  CONSTRAINT [DF_RETAILAFFILIATION_AFFILIATIONTYPE]  DEFAULT ((0)) FOR [AFFILIATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATION_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATION] ADD  CONSTRAINT [DF_RETAILAFFILIATION_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILAFFILIATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILAFFILIATIONPRICEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILAFFILIATIONPRICEGROUP](
[RECID] [bigint] NOT NULL,
[PRICEDISCGROUP] [bigint] NOT NULL,
[RETAILAFFILIATION] [bigint] NOT NULL,
[RETAILLOYALTYTIER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1865738683_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1865738683_869720144] UNIQUE NONCLUSTERED 
(
[RETAILAFFILIATION] ASC,
[PRICEDISCGROUP] ASC,
[RETAILLOYALTYTIER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATIONPRICEGROUP_PRICEDISCGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATIONPRICEGROUP] ADD  CONSTRAINT [DF_RETAILAFFILIATIONPRICEGROUP_PRICEDISCGROUP]  DEFAULT ((0)) FOR [PRICEDISCGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATIONPRICEGROUP_RETAILAFFILIATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATIONPRICEGROUP] ADD  CONSTRAINT [DF_RETAILAFFILIATIONPRICEGROUP_RETAILAFFILIATION]  DEFAULT ((0)) FOR [RETAILAFFILIATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATIONPRICEGROUP_RETAILLOYALTYTIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATIONPRICEGROUP] ADD  CONSTRAINT [DF_RETAILAFFILIATIONPRICEGROUP_RETAILLOYALTYTIER]  DEFAULT ((0)) FOR [RETAILLOYALTYTIER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILAFFILIATIONPRICEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILAFFILIATIONTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILAFFILIATIONTRANSLATION](
[RECID] [bigint] NOT NULL,
[AFFILIATION] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1948685724_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1948685724_-1107894182] UNIQUE NONCLUSTERED 
(
[LANGUAGEID] ASC,
[AFFILIATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATIONTRANSLATION_AFFILIATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATIONTRANSLATION] ADD  CONSTRAINT [DF_RETAILAFFILIATIONTRANSLATION_AFFILIATION]  DEFAULT ((0)) FOR [AFFILIATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATIONTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATIONTRANSLATION] ADD  CONSTRAINT [DF_RETAILAFFILIATIONTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILAFFILIATIONTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILAFFILIATIONTRANSLATION] ADD  CONSTRAINT [DF_RETAILAFFILIATIONTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILAFFILIATIONTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILASSORTMENTLOOKUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILASSORTMENTLOOKUP](
[RECID] [bigint] NOT NULL,
[ASSORTMENTID] [bigint] NOT NULL,
[LINETYPE] [int] NOT NULL,
[PRODUCTID] [bigint] NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[VARIANTID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1305966847_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1305966847_-835757873] UNIQUE NONCLUSTERED 
(
[ASSORTMENTID] ASC,
[PRODUCTID] ASC,
[VARIANTID] ASC,
[LINETYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUP_ASSORTMENTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUP_ASSORTMENTID]  DEFAULT ((0)) FOR [ASSORTMENTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUP_LINETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUP_LINETYPE]  DEFAULT ((0)) FOR [LINETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUP_PRODUCTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUP_PRODUCTID]  DEFAULT ((0)) FOR [PRODUCTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUP_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUP_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUP_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUP_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUP_VARIANTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUP_VARIANTID]  DEFAULT ((0)) FOR [VARIANTID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILASSORTMENTLOOKUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILASSORTMENTLOOKUPCHANNELGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILASSORTMENTLOOKUPCHANNELGROUP](
[RECID] [bigint] NOT NULL,
[ASSORTMENTID] [bigint] NOT NULL,
[OMOPERATINGUNITID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-789342849_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-789342849_-1871154347] UNIQUE NONCLUSTERED 
(
[OMOPERATINGUNITID] ASC,
[ASSORTMENTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUPCHANNELGROUP_ASSORTMENTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUPCHANNELGROUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUPCHANNELGROUP_ASSORTMENTID]  DEFAULT ((0)) FOR [ASSORTMENTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILASSORTMENTLOOKUPCHANNELGROUP_OMOPERATINGUNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILASSORTMENTLOOKUPCHANNELGROUP] ADD  CONSTRAINT [DF_RETAILASSORTMENTLOOKUPCHANNELGROUP_OMOPERATINGUNITID]  DEFAULT ((0)) FOR [OMOPERATINGUNITID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILASSORTMENTLOOKUPCHANNELGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILBARCODEMASKCHARACTER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILBARCODEMASKCHARACTER](
[RECID] [bigint] NOT NULL,
[CHARACTER] [nchar](1) NOT NULL,
[CHARACTERTYPE] [int] NOT NULL,
[COMMENT] [nvarchar](50) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-962323594_50008756] PRIMARY KEY CLUSTERED 
(
[CHARACTERTYPE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-962323594_259853196] UNIQUE NONCLUSTERED 
(
[CHARACTER] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKCHARACTER_CHARACTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKCHARACTER] ADD  CONSTRAINT [DF_RETAILBARCODEMASKCHARACTER_CHARACTER]  DEFAULT ('') FOR [CHARACTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKCHARACTER_CHARACTERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKCHARACTER] ADD  CONSTRAINT [DF_RETAILBARCODEMASKCHARACTER_CHARACTERTYPE]  DEFAULT ((0)) FOR [CHARACTERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKCHARACTER_COMMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKCHARACTER] ADD  CONSTRAINT [DF_RETAILBARCODEMASKCHARACTER_COMMENT]  DEFAULT ('') FOR [COMMENT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILBARCODEMASKCHARACTER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILBARCODEMASKSEGMENT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILBARCODEMASKSEGMENT](
[RECID] [bigint] NOT NULL,
[CHAR] [nchar](1) NOT NULL,
[DECIMALS] [int] NOT NULL,
[LENGTH] [numeric](32, 16) NOT NULL,
[MASKID] [nvarchar](10) NOT NULL,
[SEGMENTNUM] [int] NOT NULL,
[TYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1809797708_-615227758] PRIMARY KEY CLUSTERED 
(
[MASKID] ASC,
[SEGMENTNUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKSEGMENT_CHAR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKSEGMENT] ADD  CONSTRAINT [DF_RETAILBARCODEMASKSEGMENT_CHAR]  DEFAULT ('') FOR [CHAR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKSEGMENT_DECIMALS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKSEGMENT] ADD  CONSTRAINT [DF_RETAILBARCODEMASKSEGMENT_DECIMALS]  DEFAULT ((0)) FOR [DECIMALS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKSEGMENT_LENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKSEGMENT] ADD  CONSTRAINT [DF_RETAILBARCODEMASKSEGMENT_LENGTH]  DEFAULT ((0)) FOR [LENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKSEGMENT_MASKID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKSEGMENT] ADD  CONSTRAINT [DF_RETAILBARCODEMASKSEGMENT_MASKID]  DEFAULT ('') FOR [MASKID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKSEGMENT_SEGMENTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKSEGMENT] ADD  CONSTRAINT [DF_RETAILBARCODEMASKSEGMENT_SEGMENTNUM]  DEFAULT ((0)) FOR [SEGMENTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKSEGMENT_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKSEGMENT] ADD  CONSTRAINT [DF_RETAILBARCODEMASKSEGMENT_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILBARCODEMASKSEGMENT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILBARCODEMASKTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILBARCODEMASKTABLE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](50) NOT NULL,
[MASK] [nvarchar](80) NOT NULL,
[MASKID] [nvarchar](10) NOT NULL,
[PREFIX] [nvarchar](22) NOT NULL,
[SYMBOLOGY] [int] NOT NULL,
[TYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_614044725_-483433874] PRIMARY KEY CLUSTERED 
(
[MASKID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_614044725_1444299457] UNIQUE NONCLUSTERED 
(
[MASK] ASC,
[TYPE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKTABLE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKTABLE] ADD  CONSTRAINT [DF_RETAILBARCODEMASKTABLE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKTABLE_MASK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKTABLE] ADD  CONSTRAINT [DF_RETAILBARCODEMASKTABLE_MASK]  DEFAULT ('') FOR [MASK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKTABLE_MASKID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKTABLE] ADD  CONSTRAINT [DF_RETAILBARCODEMASKTABLE_MASKID]  DEFAULT ('') FOR [MASKID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKTABLE_PREFIX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKTABLE] ADD  CONSTRAINT [DF_RETAILBARCODEMASKTABLE_PREFIX]  DEFAULT ('') FOR [PREFIX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKTABLE_SYMBOLOGY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKTABLE] ADD  CONSTRAINT [DF_RETAILBARCODEMASKTABLE_SYMBOLOGY]  DEFAULT ((0)) FOR [SYMBOLOGY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBARCODEMASKTABLE_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBARCODEMASKTABLE] ADD  CONSTRAINT [DF_RETAILBARCODEMASKTABLE_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILBARCODEMASKTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILBUTTONGRID]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILBUTTONGRID](
[RECID] [bigint] NOT NULL,
[BUTTONGRIDID] [nvarchar](10) NOT NULL,
[DEFAULTCOLOR] [int] NOT NULL,
[DEFAULTFONTSIZE] [int] NOT NULL,
[DEFAULTFONTSTYLE] [int] NOT NULL,
[FONT] [nvarchar](32) NOT NULL,
[KEYBOARDUSED] [nvarchar](10) NOT NULL,
[NAME] [nvarchar](50) NOT NULL,
[SPACEBETWEENBUTTONS] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-984773215_189016630] PRIMARY KEY CLUSTERED 
(
[BUTTONGRIDID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_BUTTONGRIDID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_BUTTONGRIDID]  DEFAULT ('') FOR [BUTTONGRIDID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_DEFAULTCOLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_DEFAULTCOLOR]  DEFAULT ((0)) FOR [DEFAULTCOLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_DEFAULTFONTSIZE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_DEFAULTFONTSIZE]  DEFAULT ((0)) FOR [DEFAULTFONTSIZE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_DEFAULTFONTSTYLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_DEFAULTFONTSTYLE]  DEFAULT ((0)) FOR [DEFAULTFONTSTYLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_FONT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_FONT]  DEFAULT ('') FOR [FONT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_KEYBOARDUSED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_KEYBOARDUSED]  DEFAULT ('') FOR [KEYBOARDUSED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRID_SPACEBETWEENBUTTONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRID] ADD  CONSTRAINT [DF_RETAILBUTTONGRID_SPACEBETWEENBUTTONS]  DEFAULT ((0)) FOR [SPACEBETWEENBUTTONS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILBUTTONGRID] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILBUTTONGRIDBUTTONS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILBUTTONGRIDBUTTONS](
[RECID] [bigint] NOT NULL,
[ACTION] [int] NOT NULL,
[ACTIONPROPERTY] [nvarchar](1000) NOT NULL,
[BACKCOLOR] [int] NOT NULL,
[BACKCOLOR2] [int] NOT NULL,
[BORDERCOLOR] [int] NOT NULL,
[BUTTONGRIDID] [nvarchar](10) NOT NULL,
[COL] [int] NOT NULL,
[COLOUR] [int] NOT NULL,
[COLSPAN] [int] NOT NULL,
[DISPLAYTEXT] [nvarchar](50) NOT NULL,
[FONTCOLOR] [int] NOT NULL,
[FONTSIZE] [int] NOT NULL,
[FONTSTYLE] [int] NOT NULL,
[GRADIENTMODE] [int] NOT NULL,
[ID] [int] NOT NULL,
[IMAGEALIGNMENT] [int] NOT NULL,
[NEWIMAGEALIGNMENT] [int] NOT NULL,
[NEWTEXTALIGNMENT] [int] NOT NULL,
[PICTUREID] [int] NOT NULL,
[ROWNUM] [int] NOT NULL,
[ROWSPAN] [int] NOT NULL,
[USECUSTOMLOOKANDFEEL] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2770370_-1012477802] PRIMARY KEY CLUSTERED 
(
[ID] ASC,
[BUTTONGRIDID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_ACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_ACTION]  DEFAULT ((0)) FOR [ACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_ACTIONPROPERTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_ACTIONPROPERTY]  DEFAULT ('') FOR [ACTIONPROPERTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_BACKCOLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_BACKCOLOR]  DEFAULT ((0)) FOR [BACKCOLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_BACKCOLOR2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_BACKCOLOR2]  DEFAULT ((0)) FOR [BACKCOLOR2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_BORDERCOLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_BORDERCOLOR]  DEFAULT ((0)) FOR [BORDERCOLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_BUTTONGRIDID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_BUTTONGRIDID]  DEFAULT ('') FOR [BUTTONGRIDID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_COL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_COL]  DEFAULT ((0)) FOR [COL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_COLOUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_COLOUR]  DEFAULT ((0)) FOR [COLOUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_COLSPAN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_COLSPAN]  DEFAULT ((0)) FOR [COLSPAN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_DISPLAYTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_DISPLAYTEXT]  DEFAULT ('') FOR [DISPLAYTEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_FONTCOLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_FONTCOLOR]  DEFAULT ((0)) FOR [FONTCOLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_FONTSIZE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_FONTSIZE]  DEFAULT ((0)) FOR [FONTSIZE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_FONTSTYLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_FONTSTYLE]  DEFAULT ((0)) FOR [FONTSTYLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_GRADIENTMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_GRADIENTMODE]  DEFAULT ((0)) FOR [GRADIENTMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_ID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_ID]  DEFAULT ((0)) FOR [ID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_IMAGEALIGNMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_IMAGEALIGNMENT]  DEFAULT ((0)) FOR [IMAGEALIGNMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_NEWIMAGEALIGNMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_NEWIMAGEALIGNMENT]  DEFAULT ((0)) FOR [NEWIMAGEALIGNMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_NEWTEXTALIGNMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_NEWTEXTALIGNMENT]  DEFAULT ((0)) FOR [NEWTEXTALIGNMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_PICTUREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_PICTUREID]  DEFAULT ((0)) FOR [PICTUREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_ROWNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_ROWNUM]  DEFAULT ((0)) FOR [ROWNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_ROWSPAN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_ROWSPAN]  DEFAULT ((0)) FOR [ROWSPAN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILBUTTONGRIDBUTTONS_USECUSTOMLOOKANDFEEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILBUTTONGRIDBUTTONS] ADD  CONSTRAINT [DF_RETAILBUTTONGRIDBUTTONS_USECUSTOMLOOKANDFEEL]  DEFAULT ((0)) FOR [USECUSTOMLOOKANDFEEL]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILBUTTONGRIDBUTTONS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCATEGORYCONTAINMENTLOOKUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCATEGORYCONTAINMENTLOOKUP](
[RECID] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[CONTAINEDCATEGORY] [bigint] NOT NULL,
[ISDIRTY] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_729336743_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_729336743_496772623] UNIQUE NONCLUSTERED 
(
[CATEGORY] ASC,
[CONTAINEDCATEGORY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCATEGORYCONTAINMENTLOOKUP_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCATEGORYCONTAINMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILCATEGORYCONTAINMENTLOOKUP_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCATEGORYCONTAINMENTLOOKUP_CONTAINEDCATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCATEGORYCONTAINMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILCATEGORYCONTAINMENTLOOKUP_CONTAINEDCATEGORY]  DEFAULT ((0)) FOR [CONTAINEDCATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCATEGORYCONTAINMENTLOOKUP_ISDIRTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCATEGORYCONTAINMENTLOOKUP] ADD  CONSTRAINT [DF_RETAILCATEGORYCONTAINMENTLOOKUP_ISDIRTY]  DEFAULT ((0)) FOR [ISDIRTY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCATEGORYCONTAINMENTLOOKUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCDXDATASTORECHANNEL]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCDXDATASTORECHANNEL](
[RECID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[DATABASEPROFILE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_477722470_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_477722470_813932609] UNIQUE NONCLUSTERED 
(
[CHANNEL] ASC,
[DATABASEPROFILE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCDXDATASTORECHANNEL_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCDXDATASTORECHANNEL] ADD  CONSTRAINT [DF_RETAILCDXDATASTORECHANNEL_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCDXDATASTORECHANNEL_DATABASEPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCDXDATASTORECHANNEL] ADD  CONSTRAINT [DF_RETAILCDXDATASTORECHANNEL_DATABASEPROFILE]  DEFAULT ((0)) FOR [DATABASEPROFILE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCDXDATASTORECHANNEL] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELCURRENCY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELCURRENCY](
[RECID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_114831543_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_114831543_1078512529] UNIQUE NONCLUSTERED 
(
[CHANNEL] ASC,
[CURRENCYCODE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELCURRENCY_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELCURRENCY] ADD  CONSTRAINT [DF_RETAILCHANNELCURRENCY_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELCURRENCY_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELCURRENCY] ADD  CONSTRAINT [DF_RETAILCHANNELCURRENCY_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELCURRENCY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELPAYMENTCONNECTORLINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELPAYMENTCONNECTORLINE](
[RECID] [bigint] NOT NULL,
[ONLINECHANNEL] [bigint] NOT NULL,
[PAYMENTCONNECTORNAME] [nvarchar](50) NOT NULL,
[PAYMENTCONNECTORPROPERTIES] [nvarchar](max) NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1982148519_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPAYMENTCONNECTORLINE_ONLINECHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPAYMENTCONNECTORLINE] ADD  CONSTRAINT [DF_RETAILCHANNELPAYMENTCONNECTORLINE_ONLINECHANNEL]  DEFAULT ((0)) FOR [ONLINECHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPAYMENTCONNECTORLINE_PAYMENTCONNECTORNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPAYMENTCONNECTORLINE] ADD  CONSTRAINT [DF_RETAILCHANNELPAYMENTCONNECTORLINE_PAYMENTCONNECTORNAME]  DEFAULT ('') FOR [PAYMENTCONNECTORNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPAYMENTCONNECTORLINE_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPAYMENTCONNECTORLINE] ADD  CONSTRAINT [DF_RETAILCHANNELPAYMENTCONNECTORLINE_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPAYMENTCONNECTORLINE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPAYMENTCONNECTORLINE] ADD  CONSTRAINT [DF_RETAILCHANNELPAYMENTCONNECTORLINE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELPAYMENTCONNECTORLINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELPRICEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELPRICEGROUP](
[RECID] [bigint] NOT NULL,
[PRICEGROUP] [bigint] NOT NULL,
[RETAILCHANNEL] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-639419124_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-639419124_-99939092] UNIQUE NONCLUSTERED 
(
[RETAILCHANNEL] ASC,
[PRICEGROUP] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPRICEGROUP_PRICEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPRICEGROUP] ADD  CONSTRAINT [DF_RETAILCHANNELPRICEGROUP_PRICEGROUP]  DEFAULT ((0)) FOR [PRICEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPRICEGROUP_RETAILCHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPRICEGROUP] ADD  CONSTRAINT [DF_RETAILCHANNELPRICEGROUP_RETAILCHANNEL]  DEFAULT ((0)) FOR [RETAILCHANNEL]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELPRICEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELPROFILE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELPROFILE](
[RECID] [bigint] NOT NULL,
[CHANNELPROFILETYPE] [int] NOT NULL,
[NAME] [nvarchar](50) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-384404477_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-384404477_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPROFILE_CHANNELPROFILETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPROFILE] ADD  CONSTRAINT [DF_RETAILCHANNELPROFILE_CHANNELPROFILETYPE]  DEFAULT ((0)) FOR [CHANNELPROFILETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPROFILE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPROFILE] ADD  CONSTRAINT [DF_RETAILCHANNELPROFILE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELPROFILE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELPROFILEPROPERTY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELPROFILEPROPERTY](
[RECID] [bigint] NOT NULL,
[CHANNELPROFILE] [bigint] NOT NULL,
[KEY] [int] NOT NULL,
[VALUE] [nvarchar](1023) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-940211552_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPROFILEPROPERTY_CHANNELPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPROFILEPROPERTY] ADD  CONSTRAINT [DF_RETAILCHANNELPROFILEPROPERTY_CHANNELPROFILE]  DEFAULT ((0)) FOR [CHANNELPROFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPROFILEPROPERTY_KEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPROFILEPROPERTY] ADD  CONSTRAINT [DF_RETAILCHANNELPROFILEPROPERTY_KEY]  DEFAULT ((0)) FOR [KEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELPROFILEPROPERTY_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELPROFILEPROPERTY] ADD  CONSTRAINT [DF_RETAILCHANNELPROFILEPROPERTY_VALUE]  DEFAULT ('') FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELPROFILEPROPERTY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELREPORT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELREPORT](
[RECID] [bigint] NOT NULL,
[REPORTDEFINITIONXML] [nvarchar](max) NULL,
[REPORTID] [nvarchar](100) NOT NULL,
[REPORTNAME] [nvarchar](400) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1169491562_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1169491562_-253282476] UNIQUE NONCLUSTERED 
(
[REPORTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELREPORT_REPORTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELREPORT] ADD  CONSTRAINT [DF_RETAILCHANNELREPORT_REPORTID]  DEFAULT ('') FOR [REPORTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELREPORT_REPORTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELREPORT] ADD  CONSTRAINT [DF_RETAILCHANNELREPORT_REPORTNAME]  DEFAULT ('') FOR [REPORTNAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELREPORT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELTABLE](
[RECID] [bigint] NOT NULL,
[CHANNELTIMEZONEINFOID] [nvarchar](60) NOT NULL,
[CHANNELTYPE] [int] NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[DEFAULTCUSTACCOUNT] [nvarchar](20) NOT NULL,
[DEFAULTCUSTDATAAREAID] [nvarchar](4) NOT NULL,
[EVENTNOTIFICATIONPROFILEID] [nvarchar](20) NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[INVENTLOCATION] [nvarchar](10) NOT NULL,
[INVENTLOCATIONDATAAREAID] [nvarchar](4) NOT NULL,
[OMOPERATINGUNITID] [bigint] NOT NULL,
[PRICEINCLUDESSALESTAX] [int] NOT NULL,
[TRANSACTIONSERVICEPROFILE] [nvarchar](10) NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-922331912_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-922331912_-1636812754] UNIQUE NONCLUSTERED 
(
[OMOPERATINGUNITID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_CHANNELTIMEZONEINFOID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_CHANNELTIMEZONEINFOID]  DEFAULT ('') FOR [CHANNELTIMEZONEINFOID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_CHANNELTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_CHANNELTYPE]  DEFAULT ((0)) FOR [CHANNELTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_DEFAULTCUSTACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_DEFAULTCUSTACCOUNT]  DEFAULT ('') FOR [DEFAULTCUSTACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_DEFAULTCUSTDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_DEFAULTCUSTDATAAREAID]  DEFAULT ('') FOR [DEFAULTCUSTDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_EVENTNOTIFICATIONPROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_EVENTNOTIFICATIONPROFILEID]  DEFAULT ('') FOR [EVENTNOTIFICATIONPROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_INVENTLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_INVENTLOCATION]  DEFAULT ('') FOR [INVENTLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_INVENTLOCATIONDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_INVENTLOCATIONDATAAREAID]  DEFAULT ('') FOR [INVENTLOCATIONDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_OMOPERATINGUNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_OMOPERATINGUNITID]  DEFAULT ((0)) FOR [OMOPERATINGUNITID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_PRICEINCLUDESSALESTAX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_PRICEINCLUDESSALESTAX]  DEFAULT ((0)) FOR [PRICEINCLUDESSALESTAX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLE_TRANSACTIONSERVICEPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILCHANNELTABLE_TRANSACTIONSERVICEPROFILE]  DEFAULT ('') FOR [TRANSACTIONSERVICEPROFILE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCHANNELTABLEEXT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCHANNELTABLEEXT](
[RECID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CHANNELPROFILE] [bigint] NOT NULL,
[LIVECHANNELDATABASE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1313859313_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1313859313_69820500] UNIQUE NONCLUSTERED 
(
[CHANNEL] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLEEXT_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLEEXT] ADD  CONSTRAINT [DF_RETAILCHANNELTABLEEXT_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLEEXT_CHANNELPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLEEXT] ADD  CONSTRAINT [DF_RETAILCHANNELTABLEEXT_CHANNELPROFILE]  DEFAULT ((0)) FOR [CHANNELPROFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCHANNELTABLEEXT_LIVECHANNELDATABASE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCHANNELTABLEEXT] ADD  CONSTRAINT [DF_RETAILCHANNELTABLEEXT_LIVECHANNELDATABASE]  DEFAULT ((0)) FOR [LIVECHANNELDATABASE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCHANNELTABLEEXT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCONFIGURATION_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCONFIGURATION_BR](
[RECID] [bigint] NOT NULL,
[PURPOSE] [int] NOT NULL,
[TYPE] [int] NOT NULL,
[VALUE] [nvarchar](20) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1461688190_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONFIGURATION_BR_PURPOSE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONFIGURATION_BR] ADD  CONSTRAINT [DF_RETAILCONFIGURATION_BR_PURPOSE]  DEFAULT ((0)) FOR [PURPOSE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONFIGURATION_BR_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONFIGURATION_BR] ADD  CONSTRAINT [DF_RETAILCONFIGURATION_BR_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONFIGURATION_BR_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONFIGURATION_BR] ADD  CONSTRAINT [DF_RETAILCONFIGURATION_BR_VALUE]  DEFAULT ('') FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCONFIGURATION_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCONFIGURATIONSTORETABLE_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCONFIGURATIONSTORETABLE_BR](
[RECID] [bigint] NOT NULL,
[RETAILCONFIGURATION_BR] [bigint] NOT NULL,
[RETAILSTORETABLE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-180636695_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-180636695_586140477] UNIQUE NONCLUSTERED 
(
[RETAILCONFIGURATION_BR] ASC,
[RETAILSTORETABLE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONFIGURATIONSTORETABLE_BR_RETAILCONFIGURATION_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONFIGURATIONSTORETABLE_BR] ADD  CONSTRAINT [DF_RETAILCONFIGURATIONSTORETABLE_BR_RETAILCONFIGURATION_BR]  DEFAULT ((0)) FOR [RETAILCONFIGURATION_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONFIGURATIONSTORETABLE_BR_RETAILSTORETABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONFIGURATIONSTORETABLE_BR] ADD  CONSTRAINT [DF_RETAILCONFIGURATIONSTORETABLE_BR_RETAILSTORETABLE]  DEFAULT ((0)) FOR [RETAILSTORETABLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCONFIGURATIONSTORETABLE_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCONNDATABASEPROFILE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCONNDATABASEPROFILE](
[RECID] [bigint] NOT NULL,
[DATABASE] [nvarchar](128) NOT NULL,
[NAME] [nvarchar](50) NOT NULL,
[SERVER] [nvarchar](256) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1554329957_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1554329957_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONNDATABASEPROFILE_DATABASE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONNDATABASEPROFILE] ADD  CONSTRAINT [DF_RETAILCONNDATABASEPROFILE_DATABASE]  DEFAULT ('') FOR [DATABASE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONNDATABASEPROFILE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONNDATABASEPROFILE] ADD  CONSTRAINT [DF_RETAILCONNDATABASEPROFILE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCONNDATABASEPROFILE_SERVER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCONNDATABASEPROFILE] ADD  CONSTRAINT [DF_RETAILCONNDATABASEPROFILE_SERVER]  DEFAULT ('') FOR [SERVER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCONNDATABASEPROFILE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCUSTAFFILIATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCUSTAFFILIATION](
[RECID] [bigint] NOT NULL,
[CUSTACCOUNTNUM] [nvarchar](20) NOT NULL,
[RETAILAFFILIATIONID] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1682217268_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1682217268_1544434852] UNIQUE NONCLUSTERED 
(
[CUSTACCOUNTNUM] ASC,
[RETAILAFFILIATIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTAFFILIATION_CUSTACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTAFFILIATION] ADD  CONSTRAINT [DF_RETAILCUSTAFFILIATION_CUSTACCOUNTNUM]  DEFAULT ('') FOR [CUSTACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTAFFILIATION_RETAILAFFILIATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTAFFILIATION] ADD  CONSTRAINT [DF_RETAILCUSTAFFILIATION_RETAILAFFILIATIONID]  DEFAULT ((0)) FOR [RETAILAFFILIATIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCUSTAFFILIATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILCUSTTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILCUSTTABLE](
[RECID] [bigint] NOT NULL,
[ACCOUNTNUM] [nvarchar](20) NOT NULL,
[IMAGE] [nvarchar](1999) NOT NULL,
[NONCHARGABLEACCOUNT] [int] NOT NULL,
[POSTASSHIPMENT] [int] NOT NULL,
[RECEIPTEMAIL] [nvarchar](80) NOT NULL,
[RECEIPTOPTION] [int] NOT NULL,
[REQUIRESAPPROVAL] [int] NOT NULL,
[USEORDERNUMBERREFERENCE] [int] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-344762130_-2129881424] PRIMARY KEY CLUSTERED 
(
[ACCOUNTNUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_ACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_ACCOUNTNUM]  DEFAULT ('') FOR [ACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_IMAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_IMAGE]  DEFAULT ('') FOR [IMAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_NONCHARGABLEACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_NONCHARGABLEACCOUNT]  DEFAULT ((0)) FOR [NONCHARGABLEACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_POSTASSHIPMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_POSTASSHIPMENT]  DEFAULT ((0)) FOR [POSTASSHIPMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_RECEIPTEMAIL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_RECEIPTEMAIL]  DEFAULT ('') FOR [RECEIPTEMAIL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_RECEIPTOPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_RECEIPTOPTION]  DEFAULT ((0)) FOR [RECEIPTOPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_REQUIRESAPPROVAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_REQUIRESAPPROVAL]  DEFAULT ((0)) FOR [REQUIRESAPPROVAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_USEORDERNUMBERREFERENCE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_USEORDERNUMBERREFERENCE]  DEFAULT ((0)) FOR [USEORDERNUMBERREFERENCE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILCUSTTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILCUSTTABLE] ADD  CONSTRAINT [DF_RETAILCUSTTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILCUSTTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDEVICE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDEVICE](
[RECID] [bigint] NOT NULL,
[ACTIVATEDDATETIME] [datetime] NOT NULL,
[ACTIVATEDDATETIMETZID] [int] NOT NULL,
[ACTIVATIONSTATUS] [int] NOT NULL,
[DEACTIVATECOMMENTS] [nvarchar](256) NOT NULL,
[DEACTIVATEDDATETIME] [datetime] NOT NULL,
[DEACTIVATEDDATETIMETZID] [int] NOT NULL,
[DESCRIPTION] [nvarchar](50) NOT NULL,
[DEVICEID] [nvarchar](64) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TYPE] [bigint] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1029059569_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1029059569_-34442163] UNIQUE NONCLUSTERED 
(
[DEVICEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_ACTIVATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_ACTIVATEDDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [ACTIVATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_ACTIVATEDDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_ACTIVATEDDATETIMETZID]  DEFAULT ((37001)) FOR [ACTIVATEDDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_ACTIVATIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_ACTIVATIONSTATUS]  DEFAULT ((0)) FOR [ACTIVATIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_DEACTIVATECOMMENTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_DEACTIVATECOMMENTS]  DEFAULT ('') FOR [DEACTIVATECOMMENTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_DEACTIVATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_DEACTIVATEDDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [DEACTIVATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_DEACTIVATEDDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_DEACTIVATEDDATETIMETZID]  DEFAULT ((37001)) FOR [DEACTIVATEDDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_DEVICEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_DEVICEID]  DEFAULT ('') FOR [DEVICEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICE] ADD  CONSTRAINT [DF_RETAILDEVICE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDEVICE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDEVICETYPES]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDEVICETYPES](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[DESIGNERFORM] [int] NOT NULL,
[TYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2081582748_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2081582748_648562881] UNIQUE NONCLUSTERED 
(
[TYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICETYPES_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICETYPES] ADD  CONSTRAINT [DF_RETAILDEVICETYPES_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICETYPES_DESIGNERFORM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICETYPES] ADD  CONSTRAINT [DF_RETAILDEVICETYPES_DESIGNERFORM]  DEFAULT ((0)) FOR [DESIGNERFORM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDEVICETYPES_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDEVICETYPES] ADD  CONSTRAINT [DF_RETAILDEVICETYPES_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDEVICETYPES] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTCODE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTCODE](
[RECID] [bigint] NOT NULL,
[BARCODE] [nvarchar](80) NOT NULL,
[DISCOUNTCODE] [nvarchar](15) NOT NULL,
[DISCOUNTOFFERID] [nvarchar](20) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1508518185_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1508518185_626142578] UNIQUE NONCLUSTERED 
(
[DISCOUNTCODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTCODE_BARCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTCODE] ADD  CONSTRAINT [DF_RETAILDISCOUNTCODE_BARCODE]  DEFAULT ('') FOR [BARCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTCODE_DISCOUNTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTCODE] ADD  CONSTRAINT [DF_RETAILDISCOUNTCODE_DISCOUNTCODE]  DEFAULT ('') FOR [DISCOUNTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTCODE_DISCOUNTOFFERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTCODE] ADD  CONSTRAINT [DF_RETAILDISCOUNTCODE_DISCOUNTOFFERID]  DEFAULT ('') FOR [DISCOUNTOFFERID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTCODE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTLINEMIXANDMATCH]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTLINEMIXANDMATCH](
[RECID] [bigint] NOT NULL,
[DISCOUNTTYPE] [int] NULL,
[LINEGROUP] [nvarchar](10) NULL,
[NUMBEROFITEMSNEEDED] [int] NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1305177448_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTLINEMIXANDMATCH] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTLINEMULTIBUY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTLINEMULTIBUY](
[RECID] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1725387923_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTLINEMULTIBUY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTLINEOFFER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTLINEOFFER](
[RECID] [bigint] NOT NULL,
[DISCAMOUNT] [numeric](32, 16) NULL,
[DISCOUNTMETHOD] [int] NULL,
[DISCPCT] [numeric](32, 16) NULL,
[OFFERPRICE] [numeric](32, 16) NULL,
[OFFERPRICEINCLTAX] [numeric](32, 16) NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1716167346_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTLINEOFFER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTMIXANDMATCH]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTMIXANDMATCH](
[RECID] [bigint] NOT NULL,
[DEALPRICEVALUE] [numeric](32, 16) NULL,
[DISCOUNTAMOUNTVALUE] [numeric](32, 16) NULL,
[MIXANDMATCHDISCOUNTTYPE] [int] NULL,
[NOOFLEASTEXPENSIVELINES] [int] NULL,
[NUMBEROFTIMESAPPLICABLE] [int] NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1039421858_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTMIXANDMATCH] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTMULTIBUY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTMULTIBUY](
[RECID] [bigint] NOT NULL,
[MULTIBUYDISCOUNTTYPE] [int] NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1945564883_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTMULTIBUY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTOFFER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTOFFER](
[RECID] [bigint] NOT NULL,
[DISCONPOS] [int] NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_926028480_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTOFFER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTPRICEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTPRICEGROUP](
[RECID] [bigint] NOT NULL,
[OFFERID] [nvarchar](20) NOT NULL,
[PRICEDISCGROUP] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-755294702_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-755294702_1520629562] UNIQUE NONCLUSTERED 
(
[OFFERID] ASC,
[PRICEDISCGROUP] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTPRICEGROUP_OFFERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTPRICEGROUP] ADD  CONSTRAINT [DF_RETAILDISCOUNTPRICEGROUP_OFFERID]  DEFAULT ('') FOR [OFFERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTPRICEGROUP_PRICEDISCGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTPRICEGROUP] ADD  CONSTRAINT [DF_RETAILDISCOUNTPRICEGROUP_PRICEDISCGROUP]  DEFAULT ((0)) FOR [PRICEDISCGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTPRICEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTTHRESHOLD]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTTHRESHOLD](
[RECID] [bigint] NOT NULL,
[COUNTNONDISCOUNTITEMS] [int] NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-363700915_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTTHRESHOLD] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTTHRESHOLDTIERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTTHRESHOLDTIERS](
[RECID] [bigint] NOT NULL,
[AMOUNTTHRESHOLD] [numeric](32, 16) NOT NULL,
[DISCOUNTMETHOD] [int] NOT NULL,
[DISCOUNTVALUE] [numeric](32, 16) NOT NULL,
[OFFERID] [nvarchar](20) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1862032774_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTTHRESHOLDTIERS_AMOUNTTHRESHOLD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTTHRESHOLDTIERS] ADD  CONSTRAINT [DF_RETAILDISCOUNTTHRESHOLDTIERS_AMOUNTTHRESHOLD]  DEFAULT ((0)) FOR [AMOUNTTHRESHOLD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTTHRESHOLDTIERS_DISCOUNTMETHOD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTTHRESHOLDTIERS] ADD  CONSTRAINT [DF_RETAILDISCOUNTTHRESHOLDTIERS_DISCOUNTMETHOD]  DEFAULT ((0)) FOR [DISCOUNTMETHOD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTTHRESHOLDTIERS_DISCOUNTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTTHRESHOLDTIERS] ADD  CONSTRAINT [DF_RETAILDISCOUNTTHRESHOLDTIERS_DISCOUNTVALUE]  DEFAULT ((0)) FOR [DISCOUNTVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTTHRESHOLDTIERS_OFFERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTTHRESHOLDTIERS] ADD  CONSTRAINT [DF_RETAILDISCOUNTTHRESHOLDTIERS_OFFERID]  DEFAULT ('') FOR [OFFERID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTTHRESHOLDTIERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDISCOUNTVALIDATIONPERIOD]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD](
[RECID] [bigint] NOT NULL,
[ENDINGTIME] [int] NOT NULL,
[ENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[FRIDAYENDINGTIME] [int] NOT NULL,
[FRIDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[FRIDAYSTARTINGTIME] [int] NOT NULL,
[FRIDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[MONDAYENDINGTIME] [int] NOT NULL,
[MONDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[MONDAYSTARTINGTIME] [int] NOT NULL,
[MONDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[PERIODID] [nvarchar](10) NOT NULL,
[SATURDAYENDINGTIME] [int] NOT NULL,
[SATURDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[SATURDAYSTARTINGTIME] [int] NOT NULL,
[SATURDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[STARTINGTIME] [int] NOT NULL,
[SUNDAYENDINGTIME] [int] NOT NULL,
[SUNDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[SUNDAYSTARTINGTIME] [int] NOT NULL,
[SUNDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[THUESDAYENDINGTIME] [int] NOT NULL,
[THUESDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[THUESDAYSTARTINGTIME] [int] NOT NULL,
[THUESDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[THURSDAYENDINGTIME] [int] NOT NULL,
[THURSDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[THURSDAYSTARTINGTIME] [int] NOT NULL,
[THURSDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[TIMEWITHINBOUNDS] [int] NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[WEDNESDAYENDINGTIME] [int] NOT NULL,
[WEDNESDAYENDINGTIMEAFTERMIDNIGHT] [int] NOT NULL,
[WEDNESDAYSTARTINGTIME] [int] NOT NULL,
[WEDNESDAYTIMEWITHINBOUNDS] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1032774252_-1360894778] PRIMARY KEY CLUSTERED 
(
[PERIODID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_ENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_ENDINGTIME]  DEFAULT ((0)) FOR [ENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_ENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_ENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [ENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYENDINGTIME]  DEFAULT ((0)) FOR [FRIDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [FRIDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYSTARTINGTIME]  DEFAULT ((0)) FOR [FRIDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_FRIDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [FRIDAYTIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYENDINGTIME]  DEFAULT ((0)) FOR [MONDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [MONDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYSTARTINGTIME]  DEFAULT ((0)) FOR [MONDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_MONDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [MONDAYTIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_PERIODID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_PERIODID]  DEFAULT ('') FOR [PERIODID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYENDINGTIME]  DEFAULT ((0)) FOR [SATURDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [SATURDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYSTARTINGTIME]  DEFAULT ((0)) FOR [SATURDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SATURDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [SATURDAYTIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_STARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_STARTINGTIME]  DEFAULT ((0)) FOR [STARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYENDINGTIME]  DEFAULT ((0)) FOR [SUNDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [SUNDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYSTARTINGTIME]  DEFAULT ((0)) FOR [SUNDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_SUNDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [SUNDAYTIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYENDINGTIME]  DEFAULT ((0)) FOR [THUESDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [THUESDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYSTARTINGTIME]  DEFAULT ((0)) FOR [THUESDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THUESDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [THUESDAYTIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYENDINGTIME]  DEFAULT ((0)) FOR [THURSDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [THURSDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYSTARTINGTIME]  DEFAULT ((0)) FOR [THURSDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_THURSDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [THURSDAYTIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_TIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_TIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [TIMEWITHINBOUNDS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYENDINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYENDINGTIME]  DEFAULT ((0)) FOR [WEDNESDAYENDINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYENDINGTIMEAFTERMIDNIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYENDINGTIMEAFTERMIDNIGHT]  DEFAULT ((0)) FOR [WEDNESDAYENDINGTIMEAFTERMIDNIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYSTARTINGTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYSTARTINGTIME]  DEFAULT ((0)) FOR [WEDNESDAYSTARTINGTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYTIMEWITHINBOUNDS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDISCOUNTVALIDATIONPERIOD] ADD  CONSTRAINT [DF_RETAILDISCOUNTVALIDATIONPERIOD_WEDNESDAYTIMEWITHINBOUNDS]  DEFAULT ((0)) FOR [WEDNESDAYTIMEWITHINBOUNDS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDISCOUNTVALIDATIONPERIOD] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDLVMODEADDRESSEXPLODED]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDLVMODEADDRESSEXPLODED](
[RECID] [bigint] NOT NULL,
[COUNTRYREGION] [nvarchar](10) NOT NULL,
[DLVMODE] [bigint] NOT NULL,
[STATE] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1442873101_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1442873101_1977120800] UNIQUE NONCLUSTERED 
(
[STATE] ASC,
[DLVMODE] ASC,
[COUNTRYREGION] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODEADDRESSEXPLODED_COUNTRYREGION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODEADDRESSEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODEADDRESSEXPLODED_COUNTRYREGION]  DEFAULT ('') FOR [COUNTRYREGION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODEADDRESSEXPLODED_DLVMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODEADDRESSEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODEADDRESSEXPLODED_DLVMODE]  DEFAULT ((0)) FOR [DLVMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODEADDRESSEXPLODED_STATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODEADDRESSEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODEADDRESSEXPLODED_STATE]  DEFAULT ('') FOR [STATE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDLVMODEADDRESSEXPLODED] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDLVMODECHANNELEXPLODED]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDLVMODECHANNELEXPLODED](
[RECID] [bigint] NOT NULL,
[DLVMODE] [bigint] NOT NULL,
[OMOPERATINGUNIT] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-750738950_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-750738950_-724959869] UNIQUE NONCLUSTERED 
(
[OMOPERATINGUNIT] ASC,
[DLVMODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODECHANNELEXPLODED_DLVMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODECHANNELEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODECHANNELEXPLODED_DLVMODE]  DEFAULT ((0)) FOR [DLVMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODECHANNELEXPLODED_OMOPERATINGUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODECHANNELEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODECHANNELEXPLODED_OMOPERATINGUNIT]  DEFAULT ((0)) FOR [OMOPERATINGUNIT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDLVMODECHANNELEXPLODED] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILDLVMODEPRODUCTEXPLODED]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILDLVMODEPRODUCTEXPLODED](
[RECID] [bigint] NOT NULL,
[DLVMODE] [bigint] NOT NULL,
[INVENTDIM] [nvarchar](20) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1711265534_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1711265534_-1243541637] UNIQUE NONCLUSTERED 
(
[DLVMODE] ASC,
[ITEMID] ASC,
[INVENTDIM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODEPRODUCTEXPLODED_DLVMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODEPRODUCTEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODEPRODUCTEXPLODED_DLVMODE]  DEFAULT ((0)) FOR [DLVMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODEPRODUCTEXPLODED_INVENTDIM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODEPRODUCTEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODEPRODUCTEXPLODED_INVENTDIM]  DEFAULT ('') FOR [INVENTDIM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILDLVMODEPRODUCTEXPLODED_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILDLVMODEPRODUCTEXPLODED] ADD  CONSTRAINT [DF_RETAILDLVMODEPRODUCTEXPLODED_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILDLVMODEPRODUCTEXPLODED] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALDOCUMENTMODEL2_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR](
[CONSUMERCNPJCPFNUMBER] [nvarchar](20) NOT NULL,
[FISCALDOCUMENTACCOUNTNUM] [nvarchar](20) NOT NULL,
[FISCALDOCUMENTDATE] [date] NOT NULL,
[FISCALDOCUMENTNUMBER] [nvarchar](20) NOT NULL,
[FISCALDOCUMENTSERIES] [nvarchar](3) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STATUS] [int] NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TOTALAMOUNT] [numeric](32, 16) NOT NULL,
[TOTALDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[TOTALSURCHARGEAMOUNT] [numeric](32, 16) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-536311148_419671329] PRIMARY KEY CLUSTERED 
(
[FISCALDOCUMENTDATE] ASC,
[FISCALDOCUMENTNUMBER] ASC,
[FISCALDOCUMENTSERIES] ASC,
[TERMINALID] ASC,
[STOREID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALDOCUMENTMODEL2_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_CONSUMERCNPJCPFNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_CONSUMERCNPJCPFNUMBER]  DEFAULT ('') FOR [CONSUMERCNPJCPFNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTACCOUNTNUM]  DEFAULT ('') FOR [FISCALDOCUMENTACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTDATE]  DEFAULT ('1900-01-01') FOR [FISCALDOCUMENTDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTNUMBER]  DEFAULT ('') FOR [FISCALDOCUMENTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTSERIES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_FISCALDOCUMENTSERIES]  DEFAULT ('') FOR [FISCALDOCUMENTSERIES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_TOTALAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_TOTALAMOUNT]  DEFAULT ((0)) FOR [TOTALAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_TOTALDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_TOTALDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [TOTALDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_TOTALSURCHARGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_TOTALSURCHARGEAMOUNT]  DEFAULT ((0)) FOR [TOTALSURCHARGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALDOCUMENTMODEL2_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR](
[CFOP] [nvarchar](5) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[LINEAMOUNT] [numeric](32, 16) NOT NULL,
[LINEDISCOUNT] [numeric](32, 16) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[LINESURCHARGE] [numeric](32, 16) NOT NULL,
[QUANTITY] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[UNIT] [nvarchar](10) NOT NULL,
[UNITPRICE] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-642316962_-1103390687] PRIMARY KEY CLUSTERED 
(
[LINENUM] ASC,
[TRANSACTIONID] ASC,
[TERMINALID] ASC,
[STOREID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALDOCUMENTMODEL2LINE_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_CFOP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_CFOP]  DEFAULT ('') FOR [CFOP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINEAMOUNT]  DEFAULT ((0)) FOR [LINEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINEDISCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINEDISCOUNT]  DEFAULT ((0)) FOR [LINEDISCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINESURCHARGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_LINESURCHARGE]  DEFAULT ((0)) FOR [LINESURCHARGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_QUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_QUANTITY]  DEFAULT ((0)) FOR [QUANTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_UNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_UNIT]  DEFAULT ('') FOR [UNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_UNITPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2LINE_BR_UNITPRICE]  DEFAULT ((0)) FOR [UNITPRICE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALDOCUMENTMODEL2LINE_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR](
[FISCALVALUE] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TAXAMOUNT] [numeric](32, 16) NOT NULL,
[TAXATIONCODE] [nvarchar](3) NOT NULL,
[TAXATIONORIGIN] [int] NOT NULL,
[TAXBASEAMOUNT] [numeric](32, 16) NOT NULL,
[TAXCODE] [nvarchar](10) NOT NULL,
[TAXREDUCTIONPCT] [numeric](32, 16) NOT NULL,
[TAXTYPE] [int] NOT NULL,
[TAXVALUE] [numeric](32, 16) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1437421203_-1871252748] PRIMARY KEY CLUSTERED 
(
[LINENUM] ASC,
[TAXTYPE] ASC,
[TRANSACTIONID] ASC,
[TERMINALID] ASC,
[STOREID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_FISCALVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_FISCALVALUE]  DEFAULT ((0)) FOR [FISCALVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXAMOUNT]  DEFAULT ((0)) FOR [TAXAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXATIONCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXATIONCODE]  DEFAULT ('') FOR [TAXATIONCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXATIONORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXATIONORIGIN]  DEFAULT ((0)) FOR [TAXATIONORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXBASEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXBASEAMOUNT]  DEFAULT ((0)) FOR [TAXBASEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXCODE]  DEFAULT ('') FOR [TAXCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXREDUCTIONPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXREDUCTIONPCT]  DEFAULT ((0)) FOR [TAXREDUCTIONPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXTYPE]  DEFAULT ((0)) FOR [TAXTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TAXVALUE]  DEFAULT ((0)) FOR [TAXVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALDOCUMENTMODEL2TAXTRANS_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALPRINTER_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALPRINTER_BR](
[ADDITIONALFISCALMEMORYINDEX] [int] NOT NULL,
[FISCALESTABLISHMENT] [nvarchar](10) NOT NULL,
[FISCALRECEIPTMODEL] [nvarchar](3) NOT NULL,
[MANUFACTURER] [nvarchar](20) NOT NULL,
[MODELNUMBER] [nvarchar](30) NOT NULL,
[NATIONALCODE] [nvarchar](6) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[RESTARTOPERATIONNUMBER] [int] NOT NULL,
[SERIALNUMBER] [nvarchar](20) NOT NULL,
[SOFTWAREDATE] [date] NOT NULL,
[SOFTWAREVERSION] [nvarchar](10) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TERMINALNUMBER] [int] NOT NULL,
[TYPE] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-802645346_100835462] PRIMARY KEY CLUSTERED 
(
[SERIALNUMBER] ASC,
[ADDITIONALFISCALMEMORYINDEX] ASC,
[STOREID] ASC,
[TERMINALID] ASC,
[RESTARTOPERATIONNUMBER] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALPRINTER_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_ADDITIONALFISCALMEMORYINDEX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_ADDITIONALFISCALMEMORYINDEX]  DEFAULT ((0)) FOR [ADDITIONALFISCALMEMORYINDEX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_FISCALESTABLISHMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_FISCALESTABLISHMENT]  DEFAULT ('') FOR [FISCALESTABLISHMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_FISCALRECEIPTMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_FISCALRECEIPTMODEL]  DEFAULT ('') FOR [FISCALRECEIPTMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_MANUFACTURER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_MANUFACTURER]  DEFAULT ('') FOR [MANUFACTURER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_MODELNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_MODELNUMBER]  DEFAULT ('') FOR [MODELNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_NATIONALCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_NATIONALCODE]  DEFAULT ('') FOR [NATIONALCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_RESTARTOPERATIONNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_RESTARTOPERATIONNUMBER]  DEFAULT ((0)) FOR [RESTARTOPERATIONNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_SERIALNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_SERIALNUMBER]  DEFAULT ('') FOR [SERIALNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_SOFTWAREDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_SOFTWAREDATE]  DEFAULT ('1900-01-01') FOR [SOFTWAREDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_SOFTWAREVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_SOFTWAREVERSION]  DEFAULT ('') FOR [SOFTWAREVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_TERMINALNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_TERMINALNUMBER]  DEFAULT ((0)) FOR [TERMINALNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTER_BR_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTER_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTER_BR_TYPE]  DEFAULT ('') FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALPRINTER_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALPRINTERREPORT_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALPRINTERREPORT_BR](
[ADDITIONALFISCALMEMORYINDEX] [int] NOT NULL,
[CREDITDEBITRECEIPTNUMBER] [int] NOT NULL,
[FISCALPRINTERSERIALNUMBER] [nvarchar](20) NOT NULL,
[MANAGEMENTREPORTNUMBER] [int] NOT NULL,
[NONFISCALOPERATIONNUMBER] [int] NOT NULL,
[RECEIPTNUMBER] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[REPORTDATETIME] [datetime] NOT NULL,
[REPORTDATETIMETZID] [int] NOT NULL,
[REPORTTYPE] [nchar](2) NOT NULL,
[RESTARTOPERATIONNUMBER] [int] NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONDATETIME] [datetime] NOT NULL,
[TRANSACTIONDATETIMETZID] [int] NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1122718616_-645973167] PRIMARY KEY CLUSTERED 
(
[FISCALPRINTERSERIALNUMBER] ASC,
[ADDITIONALFISCALMEMORYINDEX] ASC,
[RESTARTOPERATIONNUMBER] ASC,
[RECEIPTNUMBER] ASC,
[TRANSACTIONID] ASC,
[STOREID] ASC,
[TERMINALID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALPRINTERREPORT_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_ADDITIONALFISCALMEMORYINDEX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_ADDITIONALFISCALMEMORYINDEX]  DEFAULT ((0)) FOR [ADDITIONALFISCALMEMORYINDEX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_CREDITDEBITRECEIPTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_CREDITDEBITRECEIPTNUMBER]  DEFAULT ((0)) FOR [CREDITDEBITRECEIPTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_FISCALPRINTERSERIALNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_FISCALPRINTERSERIALNUMBER]  DEFAULT ('') FOR [FISCALPRINTERSERIALNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_MANAGEMENTREPORTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_MANAGEMENTREPORTNUMBER]  DEFAULT ((0)) FOR [MANAGEMENTREPORTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_NONFISCALOPERATIONNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_NONFISCALOPERATIONNUMBER]  DEFAULT ((0)) FOR [NONFISCALOPERATIONNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_RECEIPTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_RECEIPTNUMBER]  DEFAULT ((0)) FOR [RECEIPTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_REPORTDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_REPORTDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [REPORTDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_REPORTDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_REPORTDATETIMETZID]  DEFAULT ((37001)) FOR [REPORTDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_REPORTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_REPORTTYPE]  DEFAULT ('') FOR [REPORTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_RESTARTOPERATIONNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_RESTARTOPERATIONNUMBER]  DEFAULT ((0)) FOR [RESTARTOPERATIONNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_TRANSACTIONDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_TRANSACTIONDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [TRANSACTIONDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_TRANSACTIONDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_TRANSACTIONDATETIMETZID]  DEFAULT ((37001)) FOR [TRANSACTIONDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALPRINTERREPORT_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALPRINTERREPORT_BR] ADD  CONSTRAINT [DF_RETAILFISCALPRINTERREPORT_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALPRINTERREPORT_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALRECEIPT_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALRECEIPT_BR](
[ACCOUNTINGDATE] [date] NOT NULL,
[ADDITIONALFISCALMEMORYINDEX] [int] NOT NULL,
[CONSUMERCNPJCPFNUMBER] [nvarchar](20) NOT NULL,
[CONSUMERNAME] [nvarchar](100) NOT NULL,
[FISCALESTABLISHMENT] [nvarchar](10) NOT NULL,
[FISCALPRINTERSERIALNUMBER] [nvarchar](20) NOT NULL,
[FISCALRECEIPTDATETIME] [datetime] NOT NULL,
[FISCALRECEIPTDATETIMETZID] [int] NOT NULL,
[FISCALRECEIPTMODEL] [nvarchar](3) NOT NULL,
[FISCALRECEIPTNUMBER] [int] NOT NULL,
[PRINTEDTOTALDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[PRINTEDTOTALSURCHARGEAMOUNT] [numeric](32, 16) NOT NULL,
[QUANTITYDECIMALS] [int] NOT NULL,
[RECEIPTNUMBER] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STATUS] [int] NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TOTALAMOUNT] [numeric](32, 16) NOT NULL,
[TOTALDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[TOTALSURCHARGEAMOUNT] [numeric](32, 16) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[UNITDECIMALS] [int] NOT NULL,
[VOIDEDAFTERENDRECEIPT] [int] NOT NULL,
[ZREPORTNUMBER] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1580227714_-397801874] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALRECEIPT_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_ACCOUNTINGDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_ACCOUNTINGDATE]  DEFAULT ('1900-01-01') FOR [ACCOUNTINGDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_ADDITIONALFISCALMEMORYINDEX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_ADDITIONALFISCALMEMORYINDEX]  DEFAULT ((0)) FOR [ADDITIONALFISCALMEMORYINDEX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_CONSUMERCNPJCPFNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_CONSUMERCNPJCPFNUMBER]  DEFAULT ('') FOR [CONSUMERCNPJCPFNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_CONSUMERNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_CONSUMERNAME]  DEFAULT ('') FOR [CONSUMERNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_FISCALESTABLISHMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_FISCALESTABLISHMENT]  DEFAULT ('') FOR [FISCALESTABLISHMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_FISCALPRINTERSERIALNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_FISCALPRINTERSERIALNUMBER]  DEFAULT ('') FOR [FISCALPRINTERSERIALNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [FISCALRECEIPTDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTDATETIMETZID]  DEFAULT ((37001)) FOR [FISCALRECEIPTDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTMODEL]  DEFAULT ('') FOR [FISCALRECEIPTMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_FISCALRECEIPTNUMBER]  DEFAULT ((0)) FOR [FISCALRECEIPTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_PRINTEDTOTALDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_PRINTEDTOTALDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [PRINTEDTOTALDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_PRINTEDTOTALSURCHARGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_PRINTEDTOTALSURCHARGEAMOUNT]  DEFAULT ((0)) FOR [PRINTEDTOTALSURCHARGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_QUANTITYDECIMALS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_QUANTITYDECIMALS]  DEFAULT ((0)) FOR [QUANTITYDECIMALS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_RECEIPTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_RECEIPTNUMBER]  DEFAULT ((0)) FOR [RECEIPTNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_TOTALAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_TOTALAMOUNT]  DEFAULT ((0)) FOR [TOTALAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_TOTALDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_TOTALDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [TOTALDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_TOTALSURCHARGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_TOTALSURCHARGEAMOUNT]  DEFAULT ((0)) FOR [TOTALSURCHARGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_UNITDECIMALS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_UNITDECIMALS]  DEFAULT ((0)) FOR [UNITDECIMALS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_VOIDEDAFTERENDRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_VOIDEDAFTERENDRECEIPT]  DEFAULT ((0)) FOR [VOIDEDAFTERENDRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPT_BR_ZREPORTNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPT_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPT_BR_ZREPORTNUMBER]  DEFAULT ((0)) FOR [ZREPORTNUMBER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALRECEIPT_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALRECEIPTLINE_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALRECEIPTLINE_BR](
[CANCELLEDQUANTITY] [numeric](32, 16) NOT NULL,
[CFOP] [nvarchar](5) NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[ITEMTYPE] [nvarchar](10) NOT NULL,
[LINEAMOUNT] [numeric](32, 16) NOT NULL,
[LINEDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[LINESURCHARGEAMOUNT] [numeric](32, 16) NOT NULL,
[PRINTEDLINEDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[PRINTEDLINESURCHARGEAMOUNT] [numeric](32, 16) NOT NULL,
[QUANTITY] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[UNIT] [nvarchar](10) NOT NULL,
[UNITPRICE] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_283734048_-1103390687] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALRECEIPTLINE_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_CANCELLEDQUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_CANCELLEDQUANTITY]  DEFAULT ((0)) FOR [CANCELLEDQUANTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_CFOP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_CFOP]  DEFAULT ('') FOR [CFOP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_ITEMTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_ITEMTYPE]  DEFAULT ('') FOR [ITEMTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_LINEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_LINEAMOUNT]  DEFAULT ((0)) FOR [LINEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_LINEDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_LINEDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [LINEDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_LINESURCHARGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_LINESURCHARGEAMOUNT]  DEFAULT ((0)) FOR [LINESURCHARGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_PRINTEDLINEDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_PRINTEDLINEDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [PRINTEDLINEDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_PRINTEDLINESURCHARGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_PRINTEDLINESURCHARGEAMOUNT]  DEFAULT ((0)) FOR [PRINTEDLINESURCHARGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_QUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_QUANTITY]  DEFAULT ((0)) FOR [QUANTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_UNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_UNIT]  DEFAULT ('') FOR [UNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTLINE_BR_UNITPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTLINE_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTLINE_BR_UNITPRICE]  DEFAULT ((0)) FOR [UNITPRICE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALRECEIPTLINE_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFISCALRECEIPTTAXTRANS_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR](
[FISCALVALUE] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TAXAMOUNT] [numeric](32, 16) NOT NULL,
[TAXATIONCODE] [nvarchar](3) NOT NULL,
[TAXBASEAMOUNT] [numeric](32, 16) NOT NULL,
[TAXCODE] [nvarchar](10) NOT NULL,
[TAXTYPE] [int] NOT NULL,
[TAXVALUE] [numeric](32, 16) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TOTALIZERINDEX] [int] NOT NULL,
[TOTALIZERNAME] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_711206165_-1871252748] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[TAXTYPE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILFISCALRECEIPTTAXTRANS_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_FISCALVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_FISCALVALUE]  DEFAULT ((0)) FOR [FISCALVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXAMOUNT]  DEFAULT ((0)) FOR [TAXAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXATIONCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXATIONCODE]  DEFAULT ('') FOR [TAXATIONCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXBASEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXBASEAMOUNT]  DEFAULT ((0)) FOR [TAXBASEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXCODE]  DEFAULT ('') FOR [TAXCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXTYPE]  DEFAULT ((0)) FOR [TAXTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TAXVALUE]  DEFAULT ((0)) FOR [TAXVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TOTALIZERINDEX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TOTALIZERINDEX]  DEFAULT ((0)) FOR [TOTALIZERINDEX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TOTALIZERNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TOTALIZERNAME]  DEFAULT ('') FOR [TOTALIZERNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFISCALRECEIPTTAXTRANS_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] ADD  CONSTRAINT [DF_RETAILFISCALRECEIPTTAXTRANS_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFISCALRECEIPTTAXTRANS_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFORMLAYOUT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFORMLAYOUT](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[FOOTERXML] [nvarchar](max) NULL,
[FORMLAYOUTID] [nvarchar](10) NOT NULL,
[HEADERXML] [nvarchar](max) NULL,
[LAYOUTTYPE] [int] NOT NULL,
[LINESXML] [nvarchar](max) NULL,
[PRINTASSLIP] [int] NOT NULL,
[PRINTBEHAVIOUR] [int] NOT NULL,
[PROMPTQUESTION] [int] NOT NULL,
[TITLE] [nvarchar](30) NOT NULL,
[UPPERCASE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1005248327_-609586253] PRIMARY KEY CLUSTERED 
(
[FORMLAYOUTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_FORMLAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_FORMLAYOUTID]  DEFAULT ('') FOR [FORMLAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_LAYOUTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_LAYOUTTYPE]  DEFAULT ((0)) FOR [LAYOUTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_PRINTASSLIP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_PRINTASSLIP]  DEFAULT ((0)) FOR [PRINTASSLIP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_PRINTBEHAVIOUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_PRINTBEHAVIOUR]  DEFAULT ((0)) FOR [PRINTBEHAVIOUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_PROMPTQUESTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_PROMPTQUESTION]  DEFAULT ((0)) FOR [PROMPTQUESTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_TITLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_TITLE]  DEFAULT ('') FOR [TITLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFORMLAYOUT_UPPERCASE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFORMLAYOUT] ADD  CONSTRAINT [DF_RETAILFORMLAYOUT_UPPERCASE]  DEFAULT ((0)) FOR [UPPERCASE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFORMLAYOUT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILFUNCTIONALITYPROFILE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILFUNCTIONALITYPROFILE](
[RECID] [bigint] NOT NULL,
[ADDTAXONPRICES] [int] NOT NULL,
[AGGREGATEITEMS] [int] NOT NULL,
[AGGREGATEITEMSFORPRINTING] [int] NOT NULL,
[AGGREGATEPAYMENTS] [int] NOT NULL,
[AMOUNTDECIMALPLACES] [nvarchar](10) NOT NULL,
[AMOUNTROUNDINGTO] [numeric](32, 16) NOT NULL,
[APPLYDISCOUNTONUNITPRICES] [int] NOT NULL,
[AUDITENABLED] [int] NOT NULL,
[BACKUPTRAININGTRANSACTIONS] [int] NOT NULL,
[BLOCKEDCLOSEDACCOUNT] [int] NOT NULL,
[CENTRALTABLESERVER] [nvarchar](256) NOT NULL,
[CENTRALTABLESERVERPORT] [nvarchar](10) NOT NULL,
[CURRENCYSYMBOL] [nvarchar](10) NOT NULL,
[DAYSCUSTOMERHISTORY] [int] NOT NULL,
[DAYSTRANSACTIONSEXISTS] [int] NOT NULL,
[DECIMALNOTREQUIREDFORMINORCURRENCYUNIT] [int] NOT NULL,
[DISCOUNTATTOTAL] [nvarchar](10) NOT NULL,
[DISPLAYSECONDARYTOTALCURRENCY] [int] NOT NULL,
[ENDOFTRANSACTION] [nvarchar](10) NOT NULL,
[EODBANKTOTALSVERIFICATION] [int] NOT NULL,
[INCLUDEKITCOMPONENTS] [int] NOT NULL,
[ITEMNOTONFILE] [nvarchar](10) NOT NULL,
[LIMITSTAFFLISTTOSTORE] [int] NOT NULL,
[LINEITEMTAXCHANGE] [nvarchar](10) NOT NULL,
[MANUALCALCULATEDISCOUNTS] [int] NOT NULL,
[MARKDOWN] [nvarchar](10) NOT NULL,
[MARKUP] [nvarchar](10) NOT NULL,
[MAXIMUMPRICE] [numeric](32, 16) NOT NULL,
[MAXIMUMQTY] [numeric](32, 16) NOT NULL,
[MAXIMUMSTORETRANSLOG] [int] NOT NULL,
[MAXTRANSACTIONSEARCHRESULTS] [int] NOT NULL,
[MINIMUMPASSWORDLENGTH] [int] NOT NULL,
[MULTIBLEITEMSYMBOL] [nvarchar](10) NOT NULL,
[MUSTKEYINPRICEIFZERO] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[NEGATIVEADJUSTMENT] [nvarchar](10) NOT NULL,
[NEGATIVESALESLINE] [nvarchar](10) NOT NULL,
[NOSALE] [nvarchar](10) NOT NULL,
[NOTAXUSED] [int] NOT NULL,
[OVERRIDEPRICE] [nvarchar](10) NOT NULL,
[PRICEDECIMALPLACES] [nvarchar](10) NOT NULL,
[PRICEROUNDINGTO] [numeric](32, 16) NOT NULL,
[PRINTXREPORTONTERMINAL] [int] NOT NULL,
[PROFILEID] [nvarchar](10) NOT NULL,
[REFUNDSALE] [nvarchar](10) NOT NULL,
[REQUIREAMOUNTDECLARATION] [int] NOT NULL,
[RETAILRECEIPTPROFILE] [nvarchar](10) NOT NULL,
[SALESPERSON] [nvarchar](10) NOT NULL,
[SALESPERSONMODE] [int] NOT NULL,
[SECONDARYTOTALCURRENCY] [nvarchar](3) NOT NULL,
[SERIALNUMBER] [nvarchar](10) NOT NULL,
[SHOWSTAFFLISTATLOGON] [int] NOT NULL,
[SKIPTAXONRECEIPT] [int] NOT NULL,
[STAFFBARCODELOGON] [int] NOT NULL,
[STAFFBARCODELOGONREQUIRESPASSWORD] [int] NOT NULL,
[STAFFCARDLOGON] [int] NOT NULL,
[STAFFCARDLOGONREQUIRESPASSWORD] [int] NOT NULL,
[STARTOFTRANSACTION] [nvarchar](10) NOT NULL,
[SUPPORTEDCOUNTRYREGIONISOCODE] [nchar](2) NOT NULL,
[TAENABLEREGISTRATION] [int] NOT NULL,
[TAXREGISTRATIONNUMBERONRECEIPT] [int] NOT NULL,
[TENDERDECLARATION] [nvarchar](10) NOT NULL,
[TRANSACTIONDELETEREMINDER] [int] NOT NULL,
[TRANSACTIONTAXCHANGE] [nvarchar](10) NOT NULL,
[TSCENTRALTABLESERVER] [int] NOT NULL,
[TSCUSTOMER] [int] NOT NULL,
[TSDATAENTRIES] [int] NOT NULL,
[TSFLOATINGCASHIER] [int] NOT NULL,
[TSINVENTORYLOOKUP] [int] NOT NULL,
[TSRESENDDELAY] [int] NOT NULL,
[TSSENDTRANSACTIONS] [int] NOT NULL,
[TSSENDVOIDTRANSACTIONS] [int] NOT NULL,
[TSSTAFF] [int] NOT NULL,
[TSSUSPENDRETRIEVETRANSACTIONS] [int] NOT NULL,
[TSTRANSACTIONRESENDLIMIT] [int] NOT NULL,
[TSUPDATEREPLICATIONCOUNTER] [int] NOT NULL,
[VOIDISPRESSED] [nvarchar](10) NOT NULL,
[VOIDPAYMENT] [nvarchar](10) NOT NULL,
[VOIDTRANSACTION] [nvarchar](10) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-953240733_-2102841330] PRIMARY KEY CLUSTERED 
(
[PROFILEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_ADDTAXONPRICES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_ADDTAXONPRICES]  DEFAULT ((0)) FOR [ADDTAXONPRICES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_AGGREGATEITEMS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_AGGREGATEITEMS]  DEFAULT ((0)) FOR [AGGREGATEITEMS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_AGGREGATEITEMSFORPRINTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_AGGREGATEITEMSFORPRINTING]  DEFAULT ((0)) FOR [AGGREGATEITEMSFORPRINTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_AGGREGATEPAYMENTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_AGGREGATEPAYMENTS]  DEFAULT ((0)) FOR [AGGREGATEPAYMENTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_AMOUNTDECIMALPLACES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_AMOUNTDECIMALPLACES]  DEFAULT ('') FOR [AMOUNTDECIMALPLACES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_AMOUNTROUNDINGTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_AMOUNTROUNDINGTO]  DEFAULT ((0)) FOR [AMOUNTROUNDINGTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_APPLYDISCOUNTONUNITPRICES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_APPLYDISCOUNTONUNITPRICES]  DEFAULT ((0)) FOR [APPLYDISCOUNTONUNITPRICES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_AUDITENABLED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_AUDITENABLED]  DEFAULT ((0)) FOR [AUDITENABLED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_BACKUPTRAININGTRANSACTIONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_BACKUPTRAININGTRANSACTIONS]  DEFAULT ((0)) FOR [BACKUPTRAININGTRANSACTIONS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_BLOCKEDCLOSEDACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_BLOCKEDCLOSEDACCOUNT]  DEFAULT ((0)) FOR [BLOCKEDCLOSEDACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_CENTRALTABLESERVER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_CENTRALTABLESERVER]  DEFAULT ('') FOR [CENTRALTABLESERVER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_CENTRALTABLESERVERPORT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_CENTRALTABLESERVERPORT]  DEFAULT ('') FOR [CENTRALTABLESERVERPORT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_CURRENCYSYMBOL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_CURRENCYSYMBOL]  DEFAULT ('') FOR [CURRENCYSYMBOL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_DAYSCUSTOMERHISTORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_DAYSCUSTOMERHISTORY]  DEFAULT ((0)) FOR [DAYSCUSTOMERHISTORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_DAYSTRANSACTIONSEXISTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_DAYSTRANSACTIONSEXISTS]  DEFAULT ((0)) FOR [DAYSTRANSACTIONSEXISTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_DECIMALNOTREQUIREDFORMINORCURRENCYUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_DECIMALNOTREQUIREDFORMINORCURRENCYUNIT]  DEFAULT ((0)) FOR [DECIMALNOTREQUIREDFORMINORCURRENCYUNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_DISCOUNTATTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_DISCOUNTATTOTAL]  DEFAULT ('') FOR [DISCOUNTATTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_DISPLAYSECONDARYTOTALCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_DISPLAYSECONDARYTOTALCURRENCY]  DEFAULT ((0)) FOR [DISPLAYSECONDARYTOTALCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_ENDOFTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_ENDOFTRANSACTION]  DEFAULT ('') FOR [ENDOFTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_EODBANKTOTALSVERIFICATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_EODBANKTOTALSVERIFICATION]  DEFAULT ((0)) FOR [EODBANKTOTALSVERIFICATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_INCLUDEKITCOMPONENTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_INCLUDEKITCOMPONENTS]  DEFAULT ((0)) FOR [INCLUDEKITCOMPONENTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_ITEMNOTONFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_ITEMNOTONFILE]  DEFAULT ('') FOR [ITEMNOTONFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_LIMITSTAFFLISTTOSTORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_LIMITSTAFFLISTTOSTORE]  DEFAULT ((0)) FOR [LIMITSTAFFLISTTOSTORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_LINEITEMTAXCHANGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_LINEITEMTAXCHANGE]  DEFAULT ('') FOR [LINEITEMTAXCHANGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MANUALCALCULATEDISCOUNTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MANUALCALCULATEDISCOUNTS]  DEFAULT ((0)) FOR [MANUALCALCULATEDISCOUNTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MARKDOWN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MARKDOWN]  DEFAULT ('') FOR [MARKDOWN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MARKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MARKUP]  DEFAULT ('') FOR [MARKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MAXIMUMPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MAXIMUMPRICE]  DEFAULT ((0)) FOR [MAXIMUMPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MAXIMUMQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MAXIMUMQTY]  DEFAULT ((0)) FOR [MAXIMUMQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MAXIMUMSTORETRANSLOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MAXIMUMSTORETRANSLOG]  DEFAULT ((0)) FOR [MAXIMUMSTORETRANSLOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MAXTRANSACTIONSEARCHRESULTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MAXTRANSACTIONSEARCHRESULTS]  DEFAULT ((0)) FOR [MAXTRANSACTIONSEARCHRESULTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MINIMUMPASSWORDLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MINIMUMPASSWORDLENGTH]  DEFAULT ((0)) FOR [MINIMUMPASSWORDLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MULTIBLEITEMSYMBOL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MULTIBLEITEMSYMBOL]  DEFAULT ('') FOR [MULTIBLEITEMSYMBOL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MUSTKEYINPRICEIFZERO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MUSTKEYINPRICEIFZERO]  DEFAULT ((0)) FOR [MUSTKEYINPRICEIFZERO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_NEGATIVEADJUSTMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_NEGATIVEADJUSTMENT]  DEFAULT ('') FOR [NEGATIVEADJUSTMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_NEGATIVESALESLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_NEGATIVESALESLINE]  DEFAULT ('') FOR [NEGATIVESALESLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_NOSALE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_NOSALE]  DEFAULT ('') FOR [NOSALE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_NOTAXUSED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_NOTAXUSED]  DEFAULT ((0)) FOR [NOTAXUSED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_OVERRIDEPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_OVERRIDEPRICE]  DEFAULT ('') FOR [OVERRIDEPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_PRICEDECIMALPLACES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_PRICEDECIMALPLACES]  DEFAULT ('') FOR [PRICEDECIMALPLACES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_PRICEROUNDINGTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_PRICEROUNDINGTO]  DEFAULT ((0)) FOR [PRICEROUNDINGTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_PRINTXREPORTONTERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_PRINTXREPORTONTERMINAL]  DEFAULT ((0)) FOR [PRINTXREPORTONTERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_PROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_PROFILEID]  DEFAULT ('') FOR [PROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_REFUNDSALE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_REFUNDSALE]  DEFAULT ('') FOR [REFUNDSALE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_REQUIREAMOUNTDECLARATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_REQUIREAMOUNTDECLARATION]  DEFAULT ((0)) FOR [REQUIREAMOUNTDECLARATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_RETAILRECEIPTPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_RETAILRECEIPTPROFILE]  DEFAULT ('') FOR [RETAILRECEIPTPROFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SALESPERSON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SALESPERSON]  DEFAULT ('') FOR [SALESPERSON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SALESPERSONMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SALESPERSONMODE]  DEFAULT ((0)) FOR [SALESPERSONMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SECONDARYTOTALCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SECONDARYTOTALCURRENCY]  DEFAULT ('') FOR [SECONDARYTOTALCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SERIALNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SERIALNUMBER]  DEFAULT ('') FOR [SERIALNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SHOWSTAFFLISTATLOGON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SHOWSTAFFLISTATLOGON]  DEFAULT ((0)) FOR [SHOWSTAFFLISTATLOGON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SKIPTAXONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SKIPTAXONRECEIPT]  DEFAULT ((0)) FOR [SKIPTAXONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_STAFFBARCODELOGON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_STAFFBARCODELOGON]  DEFAULT ((0)) FOR [STAFFBARCODELOGON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_STAFFBARCODELOGONREQUIRESPASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_STAFFBARCODELOGONREQUIRESPASSWORD]  DEFAULT ((0)) FOR [STAFFBARCODELOGONREQUIRESPASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_STAFFCARDLOGON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_STAFFCARDLOGON]  DEFAULT ((0)) FOR [STAFFCARDLOGON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_STAFFCARDLOGONREQUIRESPASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_STAFFCARDLOGONREQUIRESPASSWORD]  DEFAULT ((0)) FOR [STAFFCARDLOGONREQUIRESPASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_STARTOFTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_STARTOFTRANSACTION]  DEFAULT ('') FOR [STARTOFTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_SUPPORTEDCOUNTRYREGIONISOCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_SUPPORTEDCOUNTRYREGIONISOCODE]  DEFAULT ('') FOR [SUPPORTEDCOUNTRYREGIONISOCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TAENABLEREGISTRATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TAENABLEREGISTRATION]  DEFAULT ((0)) FOR [TAENABLEREGISTRATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TAXREGISTRATIONNUMBERONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TAXREGISTRATIONNUMBERONRECEIPT]  DEFAULT ((0)) FOR [TAXREGISTRATIONNUMBERONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TENDERDECLARATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TENDERDECLARATION]  DEFAULT ('') FOR [TENDERDECLARATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TRANSACTIONDELETEREMINDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TRANSACTIONDELETEREMINDER]  DEFAULT ((0)) FOR [TRANSACTIONDELETEREMINDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TRANSACTIONTAXCHANGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TRANSACTIONTAXCHANGE]  DEFAULT ('') FOR [TRANSACTIONTAXCHANGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSCENTRALTABLESERVER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSCENTRALTABLESERVER]  DEFAULT ((0)) FOR [TSCENTRALTABLESERVER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSCUSTOMER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSCUSTOMER]  DEFAULT ((0)) FOR [TSCUSTOMER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSDATAENTRIES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSDATAENTRIES]  DEFAULT ((0)) FOR [TSDATAENTRIES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSFLOATINGCASHIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSFLOATINGCASHIER]  DEFAULT ((0)) FOR [TSFLOATINGCASHIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSINVENTORYLOOKUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSINVENTORYLOOKUP]  DEFAULT ((0)) FOR [TSINVENTORYLOOKUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSRESENDDELAY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSRESENDDELAY]  DEFAULT ((0)) FOR [TSRESENDDELAY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSSENDTRANSACTIONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSSENDTRANSACTIONS]  DEFAULT ((0)) FOR [TSSENDTRANSACTIONS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSSENDVOIDTRANSACTIONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSSENDVOIDTRANSACTIONS]  DEFAULT ((0)) FOR [TSSENDVOIDTRANSACTIONS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSSTAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSSTAFF]  DEFAULT ((0)) FOR [TSSTAFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSSUSPENDRETRIEVETRANSACTIONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSSUSPENDRETRIEVETRANSACTIONS]  DEFAULT ((0)) FOR [TSSUSPENDRETRIEVETRANSACTIONS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSTRANSACTIONRESENDLIMIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSTRANSACTIONRESENDLIMIT]  DEFAULT ((0)) FOR [TSTRANSACTIONRESENDLIMIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_TSUPDATEREPLICATIONCOUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_TSUPDATEREPLICATIONCOUNTER]  DEFAULT ((0)) FOR [TSUPDATEREPLICATIONCOUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_VOIDISPRESSED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_VOIDISPRESSED]  DEFAULT ('') FOR [VOIDISPRESSED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_VOIDPAYMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_VOIDPAYMENT]  DEFAULT ('') FOR [VOIDPAYMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_VOIDTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_VOIDTRANSACTION]  DEFAULT ('') FOR [VOIDTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILFUNCTIONALITYPROFILE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILFUNCTIONALITYPROFILE] ADD  CONSTRAINT [DF_RETAILFUNCTIONALITYPROFILE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILFUNCTIONALITYPROFILE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILGROUPMEMBERLINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILGROUPMEMBERLINE](
[RECID] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[VARIANT] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1245137364_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILGROUPMEMBERLINE_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILGROUPMEMBERLINE] ADD  CONSTRAINT [DF_RETAILGROUPMEMBERLINE_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILGROUPMEMBERLINE_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILGROUPMEMBERLINE] ADD  CONSTRAINT [DF_RETAILGROUPMEMBERLINE_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILGROUPMEMBERLINE_VARIANT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILGROUPMEMBERLINE] ADD  CONSTRAINT [DF_RETAILGROUPMEMBERLINE_VARIANT]  DEFAULT ((0)) FOR [VARIANT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILGROUPMEMBERLINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILHARDWAREPROFILE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILHARDWAREPROFILE](
[RECID] [bigint] NOT NULL,
[CAPTUREEXTRADATA] [int] NOT NULL,
[CASHCHANGER] [int] NOT NULL,
[CASHCHANGERINITSETTINGS] [nvarchar](100) NOT NULL,
[CASHCHANGERPORTSETTINGS] [nvarchar](50) NOT NULL,
[CCTV] [int] NOT NULL,
[CCTVCAMERA] [nvarchar](60) NOT NULL,
[CCTVHOSTNAME] [nvarchar](60) NOT NULL,
[CCTVPORT] [int] NOT NULL,
[DELAYFORLINKEDITEMS] [int] NOT NULL,
[DISPLAYBALANCETEXT] [nvarchar](60) NOT NULL,
[DISPLAYBINCONVERSION] [int] NOT NULL,
[DISPLAYCHARACTERSET] [int] NOT NULL,
[DISPLAYCLOSEDLINE1] [nvarchar](60) NOT NULL,
[DISPLAYCLOSEDLINE2] [nvarchar](60) NOT NULL,
[DISPLAYDESCRIPTION] [nvarchar](60) NOT NULL,
[DISPLAYDEVICE] [int] NOT NULL,
[DISPLAYDEVICENAME] [nvarchar](60) NOT NULL,
[DISPLAYLINKEDITEM] [int] NOT NULL,
[DISPLAYTERMINALCLOSED] [int] NOT NULL,
[DISPLAYTOTALTEXT] [nvarchar](60) NOT NULL,
[DOCINSERTREMOVALTIMEOUT] [int] NOT NULL,
[DRAWER] [int] NOT NULL,
[DRAWER2] [int] NOT NULL,
[DRAWER2DESCRIPTION] [nvarchar](60) NOT NULL,
[DRAWER2DEVICENAME] [nvarchar](512) NOT NULL,
[DRAWER2MAKE] [nvarchar](30) NOT NULL,
[DRAWER2MODEL] [nvarchar](30) NOT NULL,
[DRAWERDESCRIPTION] [nvarchar](60) NOT NULL,
[DRAWERDEVICENAME] [nvarchar](512) NOT NULL,
[DRAWERMAKE] [nvarchar](30) NOT NULL,
[DRAWERMODEL] [nvarchar](30) NOT NULL,
[DUALDISPLAY] [int] NOT NULL,
[DUALDISPLAYBROWSERURL] [nvarchar](255) NOT NULL,
[DUALDISPLAYIMAGEINTERVAL] [int] NOT NULL,
[DUALDISPLAYIMAGEPATH] [nvarchar](259) NOT NULL,
[DUALDISPLAYRECEIPTPERCENTAGE] [numeric](32, 16) NOT NULL,
[DUALDISPLAYTYPE] [int] NOT NULL,
[EFT] [int] NOT NULL,
[EFTCOMPANYID] [nvarchar](50) NOT NULL,
[EFTCONFIGURATION] [int] NOT NULL,
[EFTCONNECTORNAME] [nvarchar](50) NOT NULL,
[EFTCONNECTORPROPERTIES] [nvarchar](max) NULL,
[EFTDATA] [nvarchar](128) NOT NULL,
[EFTDESCRIPTION] [nvarchar](60) NOT NULL,
[EFTMERCHANTID] [nvarchar](25) NOT NULL,
[EFTPASSWORD] [nvarchar](16) NOT NULL,
[EFTSERVERNAME] [nvarchar](80) NOT NULL,
[EFTSERVERPORT] [nvarchar](10) NOT NULL,
[EFTUSERID] [nvarchar](60) NOT NULL,
[ENDTRACK1] [nvarchar](5) NOT NULL,
[ENDTRACK2] [nchar](1) NOT NULL,
[FISCALPRINTER] [int] NOT NULL,
[FISCALPRINTERDESCRIPTION] [nvarchar](60) NOT NULL,
[FISCALPRINTERDEVICENAME] [nvarchar](512) NOT NULL,
[FORMXPOS] [int] NOT NULL,
[FORMYPOS] [int] NOT NULL,
[HARDTOTAL] [int] NOT NULL,
[HARDTOTALDESCRIPTION] [nvarchar](60) NOT NULL,
[HARDTOTALDEVICENAME] [nvarchar](512) NOT NULL,
[KEYBOARDMAPPINGID] [nvarchar](10) NOT NULL,
[KEYLOCK] [int] NOT NULL,
[KEYLOCKDESCRIPTION] [nvarchar](60) NOT NULL,
[KEYLOCKDEVICENAME] [nvarchar](512) NOT NULL,
[LOGO] [int] NOT NULL,
[LOGOALIGNMENT] [int] NOT NULL,
[LOGOBITMAP] [varbinary](max) NULL,
[MANUALINPUTALLOWED] [int] NOT NULL,
[MAXINVOICELINES] [int] NOT NULL,
[MICR] [int] NOT NULL,
[MICRDESCRIPTION] [nvarchar](60) NOT NULL,
[MICRDRIVERNAME] [nvarchar](30) NOT NULL,
[MSR] [int] NOT NULL,
[MSRDESCRIPTION] [nvarchar](60) NOT NULL,
[MSRDEVICENAME] [nvarchar](512) NOT NULL,
[MSRMAKE] [nvarchar](30) NOT NULL,
[MSRMODEL] [nvarchar](30) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[PHARMACY] [int] NOT NULL,
[PHARMACYHOST] [nvarchar](60) NOT NULL,
[PHARMACYPORT] [int] NOT NULL,
[PINPAD] [int] NOT NULL,
[PINPADDESCRIPTION] [nvarchar](60) NOT NULL,
[PINPADDEVICENAME] [nvarchar](512) NOT NULL,
[PINPADMAKE] [nvarchar](30) NOT NULL,
[PINPADMODEL] [nvarchar](30) NOT NULL,
[PRINTBINARYCONVERSION] [int] NOT NULL,
[PRINTER] [int] NOT NULL,
[PRINTER2] [int] NOT NULL,
[PRINTER2BINARYCONVERSION] [int] NOT NULL,
[PRINTER2CHARACTERSET] [int] NOT NULL,
[PRINTER2DESCRIPTION] [nvarchar](60) NOT NULL,
[PRINTER2DEVICENAME] [nvarchar](512) NOT NULL,
[PRINTER2DOCINSERTREMOVALTIMEOUT] [int] NOT NULL,
[PRINTER2LOGO] [int] NOT NULL,
[PRINTER2LOGOALIGNMENT] [int] NOT NULL,
[PRINTER2LOGOBITMAP] [varbinary](max) NULL,
[PRINTER2MAKE] [nvarchar](30) NOT NULL,
[PRINTER2MODEL] [nvarchar](30) NOT NULL,
[PRINTER2RECEIPTPROFILEID] [nvarchar](10) NOT NULL,
[PRINTERCHARACTERSET] [int] NOT NULL,
[PRINTERDESCRIPTION] [nvarchar](60) NOT NULL,
[PRINTERDEVICENAME] [nvarchar](512) NOT NULL,
[PRINTERMAKE] [nvarchar](30) NOT NULL,
[PRINTERMODEL] [nvarchar](30) NOT NULL,
[PRINTERRECEIPTPROFILEID] [nvarchar](10) NOT NULL,
[PROFILEID] [nvarchar](10) NOT NULL,
[RFIDDESCRIPTION] [nvarchar](60) NOT NULL,
[RFIDDEVICENAME] [nvarchar](512) NOT NULL,
[RFIDSCANNERTYPE] [int] NOT NULL,
[SCALE] [int] NOT NULL,
[SCALEDESCRIPTION] [nvarchar](60) NOT NULL,
[SCALEDEVICENAME] [nvarchar](512) NOT NULL,
[SCANNER] [int] NOT NULL,
[SCANNER2] [int] NOT NULL,
[SCANNER2DESCRIPTION] [nvarchar](60) NOT NULL,
[SCANNER2DEVICENAME] [nvarchar](512) NOT NULL,
[SCANNERDESCRIPTION] [nvarchar](60) NOT NULL,
[SCANNERDEVICENAME] [nvarchar](512) NOT NULL,
[SCREENKEYBOARD] [int] NOT NULL,
[SEPARATOR1] [nchar](1) NOT NULL,
[SHOWPICTURE] [int] NOT NULL,
[SIGCAP] [int] NOT NULL,
[SIGCAPDESCRIPTION] [nvarchar](60) NOT NULL,
[SIGCAPDEVICENAME] [nvarchar](512) NOT NULL,
[SIGCAPFORMNAME] [nvarchar](50) NOT NULL,
[SIGCAPMAKE] [nvarchar](30) NOT NULL,
[SIGCAPMODEL] [nvarchar](30) NOT NULL,
[STARTTRACK1] [nvarchar](5) NOT NULL,
[STARTTRACK2AFTER] [int] NOT NULL,
[TIMEOUTINSEC] [int] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1111485814_-2102841330] PRIMARY KEY CLUSTERED 
(
[PROFILEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CAPTUREEXTRADATA]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CAPTUREEXTRADATA]  DEFAULT ((0)) FOR [CAPTUREEXTRADATA]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CASHCHANGER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CASHCHANGER]  DEFAULT ((0)) FOR [CASHCHANGER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CASHCHANGERINITSETTINGS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CASHCHANGERINITSETTINGS]  DEFAULT ('') FOR [CASHCHANGERINITSETTINGS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CASHCHANGERPORTSETTINGS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CASHCHANGERPORTSETTINGS]  DEFAULT ('') FOR [CASHCHANGERPORTSETTINGS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CCTV]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CCTV]  DEFAULT ((0)) FOR [CCTV]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CCTVCAMERA]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CCTVCAMERA]  DEFAULT ('') FOR [CCTVCAMERA]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CCTVHOSTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CCTVHOSTNAME]  DEFAULT ('') FOR [CCTVHOSTNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_CCTVPORT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_CCTVPORT]  DEFAULT ((0)) FOR [CCTVPORT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DELAYFORLINKEDITEMS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DELAYFORLINKEDITEMS]  DEFAULT ((0)) FOR [DELAYFORLINKEDITEMS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYBALANCETEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYBALANCETEXT]  DEFAULT ('') FOR [DISPLAYBALANCETEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYBINCONVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYBINCONVERSION]  DEFAULT ((0)) FOR [DISPLAYBINCONVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYCHARACTERSET]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYCHARACTERSET]  DEFAULT ((0)) FOR [DISPLAYCHARACTERSET]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYCLOSEDLINE1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYCLOSEDLINE1]  DEFAULT ('') FOR [DISPLAYCLOSEDLINE1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYCLOSEDLINE2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYCLOSEDLINE2]  DEFAULT ('') FOR [DISPLAYCLOSEDLINE2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYDESCRIPTION]  DEFAULT ('') FOR [DISPLAYDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYDEVICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYDEVICE]  DEFAULT ((0)) FOR [DISPLAYDEVICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYDEVICENAME]  DEFAULT ('') FOR [DISPLAYDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYLINKEDITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYLINKEDITEM]  DEFAULT ((0)) FOR [DISPLAYLINKEDITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYTERMINALCLOSED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYTERMINALCLOSED]  DEFAULT ((0)) FOR [DISPLAYTERMINALCLOSED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DISPLAYTOTALTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DISPLAYTOTALTEXT]  DEFAULT ('') FOR [DISPLAYTOTALTEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DOCINSERTREMOVALTIMEOUT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DOCINSERTREMOVALTIMEOUT]  DEFAULT ((0)) FOR [DOCINSERTREMOVALTIMEOUT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWER]  DEFAULT ((0)) FOR [DRAWER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWER2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWER2]  DEFAULT ((0)) FOR [DRAWER2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWER2DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWER2DESCRIPTION]  DEFAULT ('') FOR [DRAWER2DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWER2DEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWER2DEVICENAME]  DEFAULT ('') FOR [DRAWER2DEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWER2MAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWER2MAKE]  DEFAULT ('') FOR [DRAWER2MAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWER2MODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWER2MODEL]  DEFAULT ('') FOR [DRAWER2MODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWERDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWERDESCRIPTION]  DEFAULT ('') FOR [DRAWERDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWERDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWERDEVICENAME]  DEFAULT ('') FOR [DRAWERDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWERMAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWERMAKE]  DEFAULT ('') FOR [DRAWERMAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DRAWERMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DRAWERMODEL]  DEFAULT ('') FOR [DRAWERMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DUALDISPLAY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DUALDISPLAY]  DEFAULT ((0)) FOR [DUALDISPLAY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DUALDISPLAYBROWSERURL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DUALDISPLAYBROWSERURL]  DEFAULT ('') FOR [DUALDISPLAYBROWSERURL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DUALDISPLAYIMAGEINTERVAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DUALDISPLAYIMAGEINTERVAL]  DEFAULT ((0)) FOR [DUALDISPLAYIMAGEINTERVAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DUALDISPLAYIMAGEPATH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DUALDISPLAYIMAGEPATH]  DEFAULT ('') FOR [DUALDISPLAYIMAGEPATH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DUALDISPLAYRECEIPTPERCENTAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DUALDISPLAYRECEIPTPERCENTAGE]  DEFAULT ((0)) FOR [DUALDISPLAYRECEIPTPERCENTAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_DUALDISPLAYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_DUALDISPLAYTYPE]  DEFAULT ((0)) FOR [DUALDISPLAYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFT]  DEFAULT ((0)) FOR [EFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTCOMPANYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTCOMPANYID]  DEFAULT ('') FOR [EFTCOMPANYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTCONFIGURATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTCONFIGURATION]  DEFAULT ((0)) FOR [EFTCONFIGURATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTCONNECTORNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTCONNECTORNAME]  DEFAULT ('') FOR [EFTCONNECTORNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTDATA]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTDATA]  DEFAULT ('') FOR [EFTDATA]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTDESCRIPTION]  DEFAULT ('') FOR [EFTDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTMERCHANTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTMERCHANTID]  DEFAULT ('') FOR [EFTMERCHANTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTPASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTPASSWORD]  DEFAULT ('') FOR [EFTPASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTSERVERNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTSERVERNAME]  DEFAULT ('') FOR [EFTSERVERNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTSERVERPORT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTSERVERPORT]  DEFAULT ('') FOR [EFTSERVERPORT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_EFTUSERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_EFTUSERID]  DEFAULT ('') FOR [EFTUSERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_ENDTRACK1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_ENDTRACK1]  DEFAULT ('') FOR [ENDTRACK1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_ENDTRACK2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_ENDTRACK2]  DEFAULT ('') FOR [ENDTRACK2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_FISCALPRINTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_FISCALPRINTER]  DEFAULT ((0)) FOR [FISCALPRINTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_FISCALPRINTERDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_FISCALPRINTERDESCRIPTION]  DEFAULT ('') FOR [FISCALPRINTERDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_FISCALPRINTERDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_FISCALPRINTERDEVICENAME]  DEFAULT ('') FOR [FISCALPRINTERDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_FORMXPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_FORMXPOS]  DEFAULT ((0)) FOR [FORMXPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_FORMYPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_FORMYPOS]  DEFAULT ((0)) FOR [FORMYPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_HARDTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_HARDTOTAL]  DEFAULT ((0)) FOR [HARDTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_HARDTOTALDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_HARDTOTALDESCRIPTION]  DEFAULT ('') FOR [HARDTOTALDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_HARDTOTALDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_HARDTOTALDEVICENAME]  DEFAULT ('') FOR [HARDTOTALDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_KEYBOARDMAPPINGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_KEYBOARDMAPPINGID]  DEFAULT ('') FOR [KEYBOARDMAPPINGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_KEYLOCK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_KEYLOCK]  DEFAULT ((0)) FOR [KEYLOCK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_KEYLOCKDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_KEYLOCKDESCRIPTION]  DEFAULT ('') FOR [KEYLOCKDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_KEYLOCKDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_KEYLOCKDEVICENAME]  DEFAULT ('') FOR [KEYLOCKDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_LOGO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_LOGO]  DEFAULT ((0)) FOR [LOGO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_LOGOALIGNMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_LOGOALIGNMENT]  DEFAULT ((0)) FOR [LOGOALIGNMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MANUALINPUTALLOWED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MANUALINPUTALLOWED]  DEFAULT ((0)) FOR [MANUALINPUTALLOWED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MAXINVOICELINES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MAXINVOICELINES]  DEFAULT ((0)) FOR [MAXINVOICELINES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MICR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MICR]  DEFAULT ((0)) FOR [MICR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MICRDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MICRDESCRIPTION]  DEFAULT ('') FOR [MICRDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MICRDRIVERNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MICRDRIVERNAME]  DEFAULT ('') FOR [MICRDRIVERNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MSR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MSR]  DEFAULT ((0)) FOR [MSR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MSRDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MSRDESCRIPTION]  DEFAULT ('') FOR [MSRDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MSRDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MSRDEVICENAME]  DEFAULT ('') FOR [MSRDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MSRMAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MSRMAKE]  DEFAULT ('') FOR [MSRMAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MSRMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MSRMODEL]  DEFAULT ('') FOR [MSRMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PHARMACY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PHARMACY]  DEFAULT ((0)) FOR [PHARMACY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PHARMACYHOST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PHARMACYHOST]  DEFAULT ('') FOR [PHARMACYHOST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PHARMACYPORT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PHARMACYPORT]  DEFAULT ((0)) FOR [PHARMACYPORT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PINPAD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PINPAD]  DEFAULT ((0)) FOR [PINPAD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PINPADDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PINPADDESCRIPTION]  DEFAULT ('') FOR [PINPADDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PINPADDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PINPADDEVICENAME]  DEFAULT ('') FOR [PINPADDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PINPADMAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PINPADMAKE]  DEFAULT ('') FOR [PINPADMAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PINPADMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PINPADMODEL]  DEFAULT ('') FOR [PINPADMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTBINARYCONVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTBINARYCONVERSION]  DEFAULT ((0)) FOR [PRINTBINARYCONVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER]  DEFAULT ((0)) FOR [PRINTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2]  DEFAULT ((0)) FOR [PRINTER2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2BINARYCONVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2BINARYCONVERSION]  DEFAULT ((0)) FOR [PRINTER2BINARYCONVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2CHARACTERSET]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2CHARACTERSET]  DEFAULT ((0)) FOR [PRINTER2CHARACTERSET]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2DESCRIPTION]  DEFAULT ('') FOR [PRINTER2DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2DEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2DEVICENAME]  DEFAULT ('') FOR [PRINTER2DEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2DOCINSERTREMOVALTIMEOUT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2DOCINSERTREMOVALTIMEOUT]  DEFAULT ((0)) FOR [PRINTER2DOCINSERTREMOVALTIMEOUT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2LOGO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2LOGO]  DEFAULT ((0)) FOR [PRINTER2LOGO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2LOGOALIGNMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2LOGOALIGNMENT]  DEFAULT ((0)) FOR [PRINTER2LOGOALIGNMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2MAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2MAKE]  DEFAULT ('') FOR [PRINTER2MAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2MODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2MODEL]  DEFAULT ('') FOR [PRINTER2MODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTER2RECEIPTPROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTER2RECEIPTPROFILEID]  DEFAULT ('') FOR [PRINTER2RECEIPTPROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTERCHARACTERSET]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTERCHARACTERSET]  DEFAULT ((0)) FOR [PRINTERCHARACTERSET]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTERDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTERDESCRIPTION]  DEFAULT ('') FOR [PRINTERDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTERDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTERDEVICENAME]  DEFAULT ('') FOR [PRINTERDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTERMAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTERMAKE]  DEFAULT ('') FOR [PRINTERMAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTERMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTERMODEL]  DEFAULT ('') FOR [PRINTERMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PRINTERRECEIPTPROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PRINTERRECEIPTPROFILEID]  DEFAULT ('') FOR [PRINTERRECEIPTPROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_PROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_PROFILEID]  DEFAULT ('') FOR [PROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_RFIDDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_RFIDDESCRIPTION]  DEFAULT ('') FOR [RFIDDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_RFIDDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_RFIDDEVICENAME]  DEFAULT ('') FOR [RFIDDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_RFIDSCANNERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_RFIDSCANNERTYPE]  DEFAULT ((0)) FOR [RFIDSCANNERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCALE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCALE]  DEFAULT ((0)) FOR [SCALE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCALEDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCALEDESCRIPTION]  DEFAULT ('') FOR [SCALEDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCALEDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCALEDEVICENAME]  DEFAULT ('') FOR [SCALEDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCANNER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCANNER]  DEFAULT ((0)) FOR [SCANNER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCANNER2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCANNER2]  DEFAULT ((0)) FOR [SCANNER2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCANNER2DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCANNER2DESCRIPTION]  DEFAULT ('') FOR [SCANNER2DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCANNER2DEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCANNER2DEVICENAME]  DEFAULT ('') FOR [SCANNER2DEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCANNERDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCANNERDESCRIPTION]  DEFAULT ('') FOR [SCANNERDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCANNERDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCANNERDEVICENAME]  DEFAULT ('') FOR [SCANNERDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SCREENKEYBOARD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SCREENKEYBOARD]  DEFAULT ((0)) FOR [SCREENKEYBOARD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SEPARATOR1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SEPARATOR1]  DEFAULT ('') FOR [SEPARATOR1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SHOWPICTURE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SHOWPICTURE]  DEFAULT ((0)) FOR [SHOWPICTURE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SIGCAP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SIGCAP]  DEFAULT ((0)) FOR [SIGCAP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SIGCAPDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SIGCAPDESCRIPTION]  DEFAULT ('') FOR [SIGCAPDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SIGCAPDEVICENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SIGCAPDEVICENAME]  DEFAULT ('') FOR [SIGCAPDEVICENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SIGCAPFORMNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SIGCAPFORMNAME]  DEFAULT ('') FOR [SIGCAPFORMNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SIGCAPMAKE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SIGCAPMAKE]  DEFAULT ('') FOR [SIGCAPMAKE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_SIGCAPMODEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_SIGCAPMODEL]  DEFAULT ('') FOR [SIGCAPMODEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_STARTTRACK1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_STARTTRACK1]  DEFAULT ('') FOR [STARTTRACK1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_STARTTRACK2AFTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_STARTTRACK2AFTER]  DEFAULT ((0)) FOR [STARTTRACK2AFTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_TIMEOUTINSEC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_TIMEOUTINSEC]  DEFAULT ((0)) FOR [TIMEOUTINSEC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILHARDWAREPROFILE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILHARDWAREPROFILE] ADD  CONSTRAINT [DF_RETAILHARDWAREPROFILE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILHARDWAREPROFILE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILIMAGES]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILIMAGES](
[RECID] [bigint] NOT NULL,
[PICTURE] [varbinary](max) NULL,
[PICTUREID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-588735509_1340322720] PRIMARY KEY CLUSTERED 
(
[PICTUREID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILIMAGES_PICTUREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILIMAGES] ADD  CONSTRAINT [DF_RETAILIMAGES_PICTUREID]  DEFAULT ((0)) FOR [PICTUREID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILIMAGES] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINCOMEEXPENSEACCOUNTTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE](
[RECID] [bigint] NOT NULL,
[ACCOUNTNUM] [nvarchar](10) NOT NULL,
[ACCOUNTTYPE] [int] NOT NULL,
[MESSAGELINE1] [nvarchar](30) NOT NULL,
[MESSAGELINE2] [nvarchar](30) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[NAMEALIAS] [nvarchar](20) NOT NULL,
[SLIPTEXT1] [nvarchar](30) NOT NULL,
[SLIPTEXT2] [nvarchar](30) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[MODIFIEDTRANSACTIONID] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1430111471_-2115689213] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[ACCOUNTNUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_ACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_ACCOUNTNUM]  DEFAULT ('') FOR [ACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_ACCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_ACCOUNTTYPE]  DEFAULT ((0)) FOR [ACCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_MESSAGELINE1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_MESSAGELINE1]  DEFAULT ('') FOR [MESSAGELINE1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_MESSAGELINE2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_MESSAGELINE2]  DEFAULT ('') FOR [MESSAGELINE2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_NAMEALIAS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_NAMEALIAS]  DEFAULT ('') FOR [NAMEALIAS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_SLIPTEXT1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_SLIPTEXT1]  DEFAULT ('') FOR [SLIPTEXT1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_SLIPTEXT2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_SLIPTEXT2]  DEFAULT ('') FOR [SLIPTEXT2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINCOMEEXPENSEACCOUNTTABLE_MODIFIEDTRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] ADD  CONSTRAINT [DF_RETAILINCOMEEXPENSEACCOUNTTABLE_MODIFIEDTRANSACTIONID]  DEFAULT ((0)) FOR [MODIFIEDTRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINCOMEEXPENSEACCOUNTTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFOCODE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFOCODE](
[RECID] [bigint] NOT NULL,
[INFOCODEID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1162389280_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1162389280_-1624030085] UNIQUE NONCLUSTERED 
(
[INFOCODEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODE_INFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODE] ADD  CONSTRAINT [DF_RETAILINFOCODE_INFOCODEID]  DEFAULT ('') FOR [INFOCODEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFOCODE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFOCODEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFOCODEGROUP](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[GROUPID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2072258145_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2072258145_1109132959] UNIQUE NONCLUSTERED 
(
[GROUPID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODEGROUP_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODEGROUP] ADD  CONSTRAINT [DF_RETAILINFOCODEGROUP_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODEGROUP_GROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODEGROUP] ADD  CONSTRAINT [DF_RETAILINFOCODEGROUP_GROUPID]  DEFAULT ('') FOR [GROUPID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFOCODEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFOCODEGROUPSPECIFIC]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFOCODEGROUPSPECIFIC](
[RECID] [bigint] NOT NULL,
[GROUPID] [nvarchar](10) NOT NULL,
[INFOCODEID] [nvarchar](10) NOT NULL,
[PRIORITY] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1342306497_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1342306497_887621465] UNIQUE NONCLUSTERED 
(
[GROUPID] ASC,
[INFOCODEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODEGROUPSPECIFIC_GROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODEGROUPSPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODEGROUPSPECIFIC_GROUPID]  DEFAULT ('') FOR [GROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODEGROUPSPECIFIC_INFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODEGROUPSPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODEGROUPSPECIFIC_INFOCODEID]  DEFAULT ('') FOR [INFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODEGROUPSPECIFIC_PRIORITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODEGROUPSPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODEGROUPSPECIFIC_PRIORITY]  DEFAULT ((0)) FOR [PRIORITY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFOCODEGROUPSPECIFIC] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFOCODETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFOCODETABLE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[INFOCODEID] [nvarchar](10) NOT NULL,
[INPUTREQUIRED] [int] NOT NULL,
[INPUTTYPE] [int] NOT NULL,
[LINKEDINFOCODEID] [nvarchar](10) NOT NULL,
[MAXIMUMLENGTH] [int] NOT NULL,
[MAXIMUMVALUE] [numeric](32, 16) NOT NULL,
[MINIMUMLENGTH] [int] NOT NULL,
[MINIMUMVALUE] [numeric](32, 16) NOT NULL,
[ONCEPERTRANSACTION] [int] NOT NULL,
[PRINTINPUTNAMEONRECEIPT] [int] NOT NULL,
[PRINTINPUTONRECEIPT] [int] NOT NULL,
[PRINTPROMPTONRECEIPT] [int] NOT NULL,
[PROMPT] [nvarchar](60) NOT NULL,
[RANDOMCOUNTER] [numeric](32, 16) NOT NULL,
[RANDOMFACTOR] [numeric](32, 16) NOT NULL,
[RETAILUSEINFOCODE] [int] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2047807304_-246962802] PRIMARY KEY CLUSTERED 
(
[INFOCODEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_INFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_INFOCODEID]  DEFAULT ('') FOR [INFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_INPUTREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_INPUTREQUIRED]  DEFAULT ((0)) FOR [INPUTREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_INPUTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_INPUTTYPE]  DEFAULT ((0)) FOR [INPUTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_LINKEDINFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_LINKEDINFOCODEID]  DEFAULT ('') FOR [LINKEDINFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_MAXIMUMLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_MAXIMUMLENGTH]  DEFAULT ((0)) FOR [MAXIMUMLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_MAXIMUMVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_MAXIMUMVALUE]  DEFAULT ((0)) FOR [MAXIMUMVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_MINIMUMLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_MINIMUMLENGTH]  DEFAULT ((0)) FOR [MINIMUMLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_MINIMUMVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_MINIMUMVALUE]  DEFAULT ((0)) FOR [MINIMUMVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_ONCEPERTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_ONCEPERTRANSACTION]  DEFAULT ((0)) FOR [ONCEPERTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_PRINTINPUTNAMEONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_PRINTINPUTNAMEONRECEIPT]  DEFAULT ((0)) FOR [PRINTINPUTNAMEONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_PRINTINPUTONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_PRINTINPUTONRECEIPT]  DEFAULT ((0)) FOR [PRINTINPUTONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_PRINTPROMPTONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_PRINTPROMPTONRECEIPT]  DEFAULT ((0)) FOR [PRINTPROMPTONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_PROMPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_PROMPT]  DEFAULT ('') FOR [PROMPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_RANDOMCOUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_RANDOMCOUNTER]  DEFAULT ((0)) FOR [RANDOMCOUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_RANDOMFACTOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_RANDOMFACTOR]  DEFAULT ((0)) FOR [RANDOMFACTOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_RETAILUSEINFOCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_RETAILUSEINFOCODE]  DEFAULT ((0)) FOR [RETAILUSEINFOCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLE] ADD  CONSTRAINT [DF_RETAILINFOCODETABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFOCODETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFOCODETABLESPECIFIC]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFOCODETABLESPECIFIC](
[RECID] [bigint] NOT NULL,
[INFOCODEID] [nvarchar](10) NOT NULL,
[INPUTREQUIRED] [int] NOT NULL,
[REFRELATION] [nvarchar](64) NOT NULL,
[REFRELATION2] [nvarchar](64) NOT NULL,
[REFRELATION3] [nvarchar](64) NOT NULL,
[REFTABLEID] [int] NOT NULL,
[SEQUENCE] [int] NOT NULL,
[WHENREQUIRED] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_798844888_-1498359599] PRIMARY KEY CLUSTERED 
(
[REFTABLEID] ASC,
[REFRELATION] ASC,
[REFRELATION2] ASC,
[REFRELATION3] ASC,
[INFOCODEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_INFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_INFOCODEID]  DEFAULT ('') FOR [INFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_INPUTREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_INPUTREQUIRED]  DEFAULT ((0)) FOR [INPUTREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_REFRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_REFRELATION]  DEFAULT ('') FOR [REFRELATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_REFRELATION2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_REFRELATION2]  DEFAULT ('') FOR [REFRELATION2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_REFRELATION3]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_REFRELATION3]  DEFAULT ('') FOR [REFRELATION3]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_REFTABLEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_REFTABLEID]  DEFAULT ((0)) FOR [REFTABLEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_SEQUENCE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_SEQUENCE]  DEFAULT ((0)) FOR [SEQUENCE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETABLESPECIFIC_WHENREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETABLESPECIFIC] ADD  CONSTRAINT [DF_RETAILINFOCODETABLESPECIFIC_WHENREQUIRED]  DEFAULT ((0)) FOR [WHENREQUIRED]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFOCODETABLESPECIFIC] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFOCODETRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFOCODETRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[INFOCODE] [bigint] NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[PROMPT] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_202291299_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_202291299_1070488980] UNIQUE NONCLUSTERED 
(
[INFOCODE] ASC,
[LANGUAGEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFOCODETRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETRANSLATION_INFOCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFOCODETRANSLATION_INFOCODE]  DEFAULT ((0)) FOR [INFOCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFOCODETRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFOCODETRANSLATION_PROMPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFOCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFOCODETRANSLATION_PROMPT]  DEFAULT ('') FOR [PROMPT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFOCODETRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFORMATIONSUBCODETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFORMATIONSUBCODETABLE](
[RECID] [bigint] NOT NULL,
[AMOUNTPERCENT] [numeric](32, 16) NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[INFOCODEID] [nvarchar](10) NOT NULL,
[NEWSALESLINE] [int] NOT NULL,
[PRICETYPE] [int] NOT NULL,
[SUBCODEID] [nvarchar](10) NOT NULL,
[TRIGGERCODE] [nvarchar](20) NOT NULL,
[TRIGGERFUNCTION] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2013310740_1087960115] PRIMARY KEY CLUSTERED 
(
[INFOCODEID] ASC,
[SUBCODEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_AMOUNTPERCENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_AMOUNTPERCENT]  DEFAULT ((0)) FOR [AMOUNTPERCENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_INFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_INFOCODEID]  DEFAULT ('') FOR [INFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_NEWSALESLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_NEWSALESLINE]  DEFAULT ((0)) FOR [NEWSALESLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_PRICETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_PRICETYPE]  DEFAULT ((0)) FOR [PRICETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_SUBCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_SUBCODEID]  DEFAULT ('') FOR [SUBCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_TRIGGERCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_TRIGGERCODE]  DEFAULT ('') FOR [TRIGGERCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETABLE_TRIGGERFUNCTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETABLE] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETABLE_TRIGGERFUNCTION]  DEFAULT ((0)) FOR [TRIGGERFUNCTION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFORMATIONSUBCODETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINFORMATIONSUBCODETRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINFORMATIONSUBCODETRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[INFOSUBCODE] [bigint] NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1974585269_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1974585269_-310291638] UNIQUE NONCLUSTERED 
(
[INFOSUBCODE] ASC,
[LANGUAGEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETRANSLATION_INFOSUBCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETRANSLATION_INFOSUBCODE]  DEFAULT ((0)) FOR [INFOSUBCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINFORMATIONSUBCODETRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINFORMATIONSUBCODETRANSLATION] ADD  CONSTRAINT [DF_RETAILINFORMATIONSUBCODETRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINFORMATIONSUBCODETRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINTERNALORGANIZATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINTERNALORGANIZATION](
[RECID] [bigint] NOT NULL,
[INTERNALORGANIZATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_423793179_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_423793179_1393859730] UNIQUE NONCLUSTERED 
(
[INTERNALORGANIZATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINTERNALORGANIZATION_INTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINTERNALORGANIZATION] ADD  CONSTRAINT [DF_RETAILINTERNALORGANIZATION_INTERNALORGANIZATION]  DEFAULT ((0)) FOR [INTERNALORGANIZATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINTERNALORGANIZATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINVENTAVAILABILITY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINVENTAVAILABILITY](
[RECID] [bigint] NOT NULL,
[AVAILPHYSICAL] [numeric](32, 16) NOT NULL,
[INVENTDIMRECID] [bigint] NOT NULL,
[ITEMRECID] [bigint] NOT NULL,
[LASTINVENTTRANS] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-155348074_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-155348074_789383996] UNIQUE NONCLUSTERED 
(
[ITEMRECID] ASC,
[INVENTDIMRECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTAVAILABILITY_AVAILPHYSICAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTAVAILABILITY] ADD  CONSTRAINT [DF_RETAILINVENTAVAILABILITY_AVAILPHYSICAL]  DEFAULT ((0)) FOR [AVAILPHYSICAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTAVAILABILITY_INVENTDIMRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTAVAILABILITY] ADD  CONSTRAINT [DF_RETAILINVENTAVAILABILITY_INVENTDIMRECID]  DEFAULT ((0)) FOR [INVENTDIMRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTAVAILABILITY_ITEMRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTAVAILABILITY] ADD  CONSTRAINT [DF_RETAILINVENTAVAILABILITY_ITEMRECID]  DEFAULT ((0)) FOR [ITEMRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTAVAILABILITY_LASTINVENTTRANS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTAVAILABILITY] ADD  CONSTRAINT [DF_RETAILINVENTAVAILABILITY_LASTINVENTTRANS]  DEFAULT ((0)) FOR [LASTINVENTTRANS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINVENTAVAILABILITY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINVENTLINKEDITEM]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINVENTLINKEDITEM](
[RECID] [bigint] NOT NULL,
[BLOCKED] [int] NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[LINKEDITEMID] [nvarchar](20) NOT NULL,
[QTY] [numeric](32, 16) NOT NULL,
[UNIT] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-126780815_-221054464] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[UNIT] ASC,
[LINKEDITEMID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTLINKEDITEM_BLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTLINKEDITEM] ADD  CONSTRAINT [DF_RETAILINVENTLINKEDITEM_BLOCKED]  DEFAULT ((0)) FOR [BLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTLINKEDITEM_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTLINKEDITEM] ADD  CONSTRAINT [DF_RETAILINVENTLINKEDITEM_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTLINKEDITEM_LINKEDITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTLINKEDITEM] ADD  CONSTRAINT [DF_RETAILINVENTLINKEDITEM_LINKEDITEMID]  DEFAULT ('') FOR [LINKEDITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTLINKEDITEM_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTLINKEDITEM] ADD  CONSTRAINT [DF_RETAILINVENTLINKEDITEM_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTLINKEDITEM_UNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTLINKEDITEM] ADD  CONSTRAINT [DF_RETAILINVENTLINKEDITEM_UNIT]  DEFAULT ('') FOR [UNIT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINVENTLINKEDITEM] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILINVENTTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILINVENTTABLE](
[RECID] [bigint] NOT NULL,
[BARCODESETUPID] [nvarchar](10) NOT NULL,
[BASECOMPARISONUNITCODE] [nvarchar](10) NOT NULL,
[BLOCKEDONPOS] [int] NOT NULL,
[DATEBLOCKED] [date] NOT NULL,
[DATETOACTIVATEITEM] [date] NOT NULL,
[DATETOBEBLOCKED] [date] NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[KEYINGINPRICE] [int] NOT NULL,
[KEYINGINQTY] [int] NOT NULL,
[MUSTKEYINCOMMENT] [int] NOT NULL,
[NODISCOUNTALLOWED] [int] NOT NULL,
[PRINTVARIANTSSHELFLABELS] [int] NOT NULL,
[PROHIBITRETURN_RU] [int] NOT NULL,
[QTYBECOMESNEGATIVE] [int] NOT NULL,
[SCALEITEM] [int] NOT NULL,
[USEEANSTANDARDBARCODE] [int] NOT NULL,
[ZEROPRICEVALID] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1553584605_1428044496] PRIMARY KEY CLUSTERED 
(
[ITEMID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_BARCODESETUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_BARCODESETUPID]  DEFAULT ('') FOR [BARCODESETUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_BASECOMPARISONUNITCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_BASECOMPARISONUNITCODE]  DEFAULT ('') FOR [BASECOMPARISONUNITCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_BLOCKEDONPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_BLOCKEDONPOS]  DEFAULT ((0)) FOR [BLOCKEDONPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_DATEBLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_DATEBLOCKED]  DEFAULT ('1900-01-01') FOR [DATEBLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_DATETOACTIVATEITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_DATETOACTIVATEITEM]  DEFAULT ('1900-01-01') FOR [DATETOACTIVATEITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_DATETOBEBLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_DATETOBEBLOCKED]  DEFAULT ('1900-01-01') FOR [DATETOBEBLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_KEYINGINPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_KEYINGINPRICE]  DEFAULT ((0)) FOR [KEYINGINPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_KEYINGINQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_KEYINGINQTY]  DEFAULT ((0)) FOR [KEYINGINQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_MUSTKEYINCOMMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_MUSTKEYINCOMMENT]  DEFAULT ((0)) FOR [MUSTKEYINCOMMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_NODISCOUNTALLOWED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_NODISCOUNTALLOWED]  DEFAULT ((0)) FOR [NODISCOUNTALLOWED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_PRINTVARIANTSSHELFLABELS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_PRINTVARIANTSSHELFLABELS]  DEFAULT ((0)) FOR [PRINTVARIANTSSHELFLABELS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_PROHIBITRETURN_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_PROHIBITRETURN_RU]  DEFAULT ((0)) FOR [PROHIBITRETURN_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_QTYBECOMESNEGATIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_QTYBECOMESNEGATIVE]  DEFAULT ((0)) FOR [QTYBECOMESNEGATIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_SCALEITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_SCALEITEM]  DEFAULT ((0)) FOR [SCALEITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_USEEANSTANDARDBARCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_USEEANSTANDARDBARCODE]  DEFAULT ((0)) FOR [USEEANSTANDARDBARCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILINVENTTABLE_ZEROPRICEVALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILINVENTTABLE] ADD  CONSTRAINT [DF_RETAILINVENTTABLE_ZEROPRICEVALID]  DEFAULT ((0)) FOR [ZEROPRICEVALID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILINVENTTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILJOBPOSPERMISSIONGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILJOBPOSPERMISSIONGROUP](
[RECID] [bigint] NOT NULL,
[JOB] [bigint] NOT NULL,
[RETAILPOSPERMISSIONGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_495795012_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_495795012_-384136432] UNIQUE NONCLUSTERED 
(
[JOB] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILJOBPOSPERMISSIONGROUP_JOB]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILJOBPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILJOBPOSPERMISSIONGROUP_JOB]  DEFAULT ((0)) FOR [JOB]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILJOBPOSPERMISSIONGROUP_RETAILPOSPERMISSIONGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILJOBPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILJOBPOSPERMISSIONGROUP_RETAILPOSPERMISSIONGROUP]  DEFAULT ((0)) FOR [RETAILPOSPERMISSIONGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILJOBPOSPERMISSIONGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKEYBOARDBUTTONCONTROL]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL](
[RECID] [bigint] NOT NULL,
[BUTTONCONTROLID] [int] NOT NULL,
[DEFAULTCOLOR] [nvarchar](10) NOT NULL,
[DEFAULTFONT] [nvarchar](32) NOT NULL,
[DEFAULTFONTSIZE] [int] NOT NULL,
[DEFAULTFONTSTYLE] [int] NOT NULL,
[NAME] [nvarchar](50) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_316740147_-1011273354] PRIMARY KEY CLUSTERED 
(
[BUTTONCONTROLID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROL_BUTTONCONTROLID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROL_BUTTONCONTROLID]  DEFAULT ((0)) FOR [BUTTONCONTROLID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTCOLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTCOLOR]  DEFAULT ('') FOR [DEFAULTCOLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTFONT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTFONT]  DEFAULT ('') FOR [DEFAULTFONT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTFONTSIZE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTFONTSIZE]  DEFAULT ((0)) FOR [DEFAULTFONTSIZE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTFONTSTYLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROL_DEFAULTFONTSTYLE]  DEFAULT ((0)) FOR [DEFAULTFONTSTYLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROL_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROL] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROL_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKEYBOARDBUTTONCONTROL] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKEYBOARDBUTTONCONTROLB]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB](
[RECID] [bigint] NOT NULL,
[ACTION] [int] NOT NULL,
[ACTIONPROPERTY] [nvarchar](1000) NOT NULL,
[BUTTONCONTROLID] [int] NOT NULL,
[COLOUR] [nvarchar](20) NOT NULL,
[DISPLAYTEXT] [nvarchar](50) NOT NULL,
[FONTSIZE] [int] NOT NULL,
[FONTSTYLE] [int] NOT NULL,
[ID] [int] NOT NULL,
[PICTURE] [nvarchar](max) NULL,
[ROWNUM] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_876263485_-594239886] PRIMARY KEY CLUSTERED 
(
[ID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_ACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_ACTION]  DEFAULT ((0)) FOR [ACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_ACTIONPROPERTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_ACTIONPROPERTY]  DEFAULT ('') FOR [ACTIONPROPERTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_BUTTONCONTROLID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_BUTTONCONTROLID]  DEFAULT ((0)) FOR [BUTTONCONTROLID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_COLOUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_COLOUR]  DEFAULT ('') FOR [COLOUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_DISPLAYTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_DISPLAYTEXT]  DEFAULT ('') FOR [DISPLAYTEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_FONTSIZE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_FONTSIZE]  DEFAULT ((0)) FOR [FONTSIZE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_FONTSTYLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_FONTSTYLE]  DEFAULT ((0)) FOR [FONTSTYLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_ID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_ID]  DEFAULT ((0)) FOR [ID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDBUTTONCONTROLB_ROWNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDBUTTONCONTROLB] ADD  CONSTRAINT [DF_RETAILKEYBOARDBUTTONCONTROLB_ROWNUM]  DEFAULT ((0)) FOR [ROWNUM]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKEYBOARDBUTTONCONTROLB] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKEYBOARDMAPPINGTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKEYBOARDMAPPINGTABLE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[KEYBOARDMAPPINGID] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1200005738_96064522] PRIMARY KEY CLUSTERED 
(
[KEYBOARDMAPPINGID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTABLE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTABLE] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTABLE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTABLE_KEYBOARDMAPPINGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTABLE] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTABLE_KEYBOARDMAPPINGID]  DEFAULT ('') FOR [KEYBOARDMAPPINGID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKEYBOARDMAPPINGTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKEYBOARDMAPPINGTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKEYBOARDMAPPINGTRANS](
[RECID] [bigint] NOT NULL,
[ACTION] [int] NOT NULL,
[ACTIONPROPERTY] [nvarchar](1000) NOT NULL,
[ASCIIVALUE] [int] NOT NULL,
[KEYBOARDMAPPINGID] [nvarchar](10) NOT NULL,
[KEYCHAR] [nchar](1) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1979216936_-159151230] PRIMARY KEY CLUSTERED 
(
[KEYBOARDMAPPINGID] ASC,
[ASCIIVALUE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTRANS_ACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTRANS] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTRANS_ACTION]  DEFAULT ((0)) FOR [ACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTRANS_ACTIONPROPERTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTRANS] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTRANS_ACTIONPROPERTY]  DEFAULT ('') FOR [ACTIONPROPERTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTRANS_ASCIIVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTRANS] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTRANS_ASCIIVALUE]  DEFAULT ((0)) FOR [ASCIIVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTRANS_KEYBOARDMAPPINGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTRANS] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTRANS_KEYBOARDMAPPINGID]  DEFAULT ('') FOR [KEYBOARDMAPPINGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKEYBOARDMAPPINGTRANS_KEYCHAR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKEYBOARDMAPPINGTRANS] ADD  CONSTRAINT [DF_RETAILKEYBOARDMAPPINGTRANS_KEYCHAR]  DEFAULT ('') FOR [KEYCHAR]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKEYBOARDMAPPINGTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKIT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKIT](
[RECID] [bigint] NOT NULL,
[DISASSEMBLYATREGISTERALLOWED] [int] NOT NULL,
[DISCONTINUEKIT] [int] NOT NULL,
[PRODUCTMASTER] [bigint] NOT NULL,
[STATUS] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_209556489_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_209556489_1729947418] UNIQUE NONCLUSTERED 
(
[PRODUCTMASTER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKIT_DISASSEMBLYATREGISTERALLOWED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKIT] ADD  CONSTRAINT [DF_RETAILKIT_DISASSEMBLYATREGISTERALLOWED]  DEFAULT ((0)) FOR [DISASSEMBLYATREGISTERALLOWED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKIT_DISCONTINUEKIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKIT] ADD  CONSTRAINT [DF_RETAILKIT_DISCONTINUEKIT]  DEFAULT ((0)) FOR [DISCONTINUEKIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKIT_PRODUCTMASTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKIT] ADD  CONSTRAINT [DF_RETAILKIT_PRODUCTMASTER]  DEFAULT ((0)) FOR [PRODUCTMASTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKIT_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKIT] ADD  CONSTRAINT [DF_RETAILKIT_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKIT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKITCOMPONENT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKITCOMPONENT](
[RECID] [bigint] NOT NULL,
[COMPONENT] [bigint] NOT NULL,
[DONOTSHOWATREGISTER] [int] NOT NULL,
[KIT] [bigint] NOT NULL,
[QUANTITY] [numeric](32, 16) NOT NULL,
[UNITOFMEASURE] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_816282606_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_COMPONENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_COMPONENT]  DEFAULT ((0)) FOR [COMPONENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_DONOTSHOWATREGISTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_DONOTSHOWATREGISTER]  DEFAULT ((0)) FOR [DONOTSHOWATREGISTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_KIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_KIT]  DEFAULT ((0)) FOR [KIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_QUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_QUANTITY]  DEFAULT ((0)) FOR [QUANTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_UNITOFMEASURE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_UNITOFMEASURE]  DEFAULT ((0)) FOR [UNITOFMEASURE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENT_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITCOMPONENT_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKITCOMPONENT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKITCOMPONENTSUBSTITUTE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKITCOMPONENTSUBSTITUTE](
[RECID] [bigint] NOT NULL,
[KITCOMPONENT] [bigint] NOT NULL,
[QUANTITY] [numeric](32, 16) NOT NULL,
[SUBSTITUTEPRODUCT] [bigint] NOT NULL,
[UNITOFMEASURE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1352945126_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1352945126_160563956] UNIQUE NONCLUSTERED 
(
[KITCOMPONENT] ASC,
[SUBSTITUTEPRODUCT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENTSUBSTITUTE_KITCOMPONENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENTSUBSTITUTE] ADD  CONSTRAINT [DF_RETAILKITCOMPONENTSUBSTITUTE_KITCOMPONENT]  DEFAULT ((0)) FOR [KITCOMPONENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENTSUBSTITUTE_QUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENTSUBSTITUTE] ADD  CONSTRAINT [DF_RETAILKITCOMPONENTSUBSTITUTE_QUANTITY]  DEFAULT ((0)) FOR [QUANTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENTSUBSTITUTE_SUBSTITUTEPRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENTSUBSTITUTE] ADD  CONSTRAINT [DF_RETAILKITCOMPONENTSUBSTITUTE_SUBSTITUTEPRODUCT]  DEFAULT ((0)) FOR [SUBSTITUTEPRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITCOMPONENTSUBSTITUTE_UNITOFMEASURE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITCOMPONENTSUBSTITUTE] ADD  CONSTRAINT [DF_RETAILKITCOMPONENTSUBSTITUTE_UNITOFMEASURE]  DEFAULT ((0)) FOR [UNITOFMEASURE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKITCOMPONENTSUBSTITUTE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKITRELEASEDSUBSTITUTECHARGE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKITRELEASEDSUBSTITUTECHARGE](
[RECID] [bigint] NOT NULL,
[KITCOMPONENTSUBSTITUTE] [bigint] NOT NULL,
[SUBSTITUTECHARGE] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1490136328_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITRELEASEDSUBSTITUTECHARGE_KITCOMPONENTSUBSTITUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITRELEASEDSUBSTITUTECHARGE] ADD  CONSTRAINT [DF_RETAILKITRELEASEDSUBSTITUTECHARGE_KITCOMPONENTSUBSTITUTE]  DEFAULT ((0)) FOR [KITCOMPONENTSUBSTITUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITRELEASEDSUBSTITUTECHARGE_SUBSTITUTECHARGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITRELEASEDSUBSTITUTECHARGE] ADD  CONSTRAINT [DF_RETAILKITRELEASEDSUBSTITUTECHARGE_SUBSTITUTECHARGE]  DEFAULT ((0)) FOR [SUBSTITUTECHARGE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKITRELEASEDSUBSTITUTECHARGE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILKITVARIANTCOMPONENT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILKITVARIANTCOMPONENT](
[RECID] [bigint] NOT NULL,
[COMPONENT] [bigint] NOT NULL,
[COMPONENTRECID] [bigint] NOT NULL,
[KITVARIANT] [bigint] NOT NULL,
[QUANTITY] [numeric](32, 16) NOT NULL,
[UNITOFMEASURE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1748165813_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1748165813_1499849031] UNIQUE NONCLUSTERED 
(
[KITVARIANT] ASC,
[COMPONENT] ASC,
[COMPONENTRECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITVARIANTCOMPONENT_COMPONENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITVARIANTCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITVARIANTCOMPONENT_COMPONENT]  DEFAULT ((0)) FOR [COMPONENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITVARIANTCOMPONENT_COMPONENTRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITVARIANTCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITVARIANTCOMPONENT_COMPONENTRECID]  DEFAULT ((0)) FOR [COMPONENTRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITVARIANTCOMPONENT_KITVARIANT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITVARIANTCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITVARIANTCOMPONENT_KITVARIANT]  DEFAULT ((0)) FOR [KITVARIANT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITVARIANTCOMPONENT_QUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITVARIANTCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITVARIANTCOMPONENT_QUANTITY]  DEFAULT ((0)) FOR [QUANTITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILKITVARIANTCOMPONENT_UNITOFMEASURE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILKITVARIANTCOMPONENT] ADD  CONSTRAINT [DF_RETAILKITVARIANTCOMPONENT_UNITOFMEASURE]  DEFAULT ((0)) FOR [UNITOFMEASURE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILKITVARIANTCOMPONENT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLANGUAGETEXT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLANGUAGETEXT](
[RECID] [bigint] NOT NULL,
[ACTIVE] [int] NOT NULL,
[DATECREATED] [date] NOT NULL,
[DATEUPDATED] [date] NOT NULL,
[ERRORTEXT] [int] NOT NULL,
[FIRSTINVERSION] [nvarchar](20) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[MODULEID] [int] NOT NULL,
[TEXT] [nvarchar](250) NOT NULL,
[TEXTID] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1986448268_2004151621] PRIMARY KEY CLUSTERED 
(
[LANGUAGEID] ASC,
[TEXTID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_ACTIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_ACTIVE]  DEFAULT ((0)) FOR [ACTIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_DATECREATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_DATECREATED]  DEFAULT ('1900-01-01') FOR [DATECREATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_DATEUPDATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_DATEUPDATED]  DEFAULT ('1900-01-01') FOR [DATEUPDATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_ERRORTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_ERRORTEXT]  DEFAULT ((0)) FOR [ERRORTEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_FIRSTINVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_FIRSTINVERSION]  DEFAULT ('') FOR [FIRSTINVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_MODULEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_MODULEID]  DEFAULT ((0)) FOR [MODULEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_TEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_TEXT]  DEFAULT ('') FOR [TEXT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLANGUAGETEXT_TEXTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLANGUAGETEXT] ADD  CONSTRAINT [DF_RETAILLANGUAGETEXT_TEXTID]  DEFAULT ((0)) FOR [TEXTID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLANGUAGETEXT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLISTINGSTATUSLOG]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLISTINGSTATUSLOG](
[ACTIONSTATUS] [int] NOT NULL,
[APPLIEDACTION] [int] NOT NULL,
[CATALOG] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CHANNELLISTINGID] [nvarchar](50) NOT NULL,
[LISTINGMODIFIEDDATETIME] [datetime] NOT NULL,
[LISTINGMODIFIEDDATETIMETZID] [int] NOT NULL,
[PROCESSED] [int] NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STATUSDATETIME] [datetime] NOT NULL,
[STATUSDATETIMETZID] [int] NOT NULL,
[STATUSMESSAGE] [nvarchar](2048) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2129744063_-2139665100] PRIMARY KEY CLUSTERED 
(
[PRODUCT] ASC,
[CATALOG] ASC,
[CHANNEL] ASC,
[LISTINGMODIFIEDDATETIME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILLISTINGSTATUSLOG_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_ACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_ACTIONSTATUS]  DEFAULT ((0)) FOR [ACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_APPLIEDACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_APPLIEDACTION]  DEFAULT ((0)) FOR [APPLIEDACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_CATALOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_CATALOG]  DEFAULT ((0)) FOR [CATALOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_CHANNELLISTINGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_CHANNELLISTINGID]  DEFAULT ('') FOR [CHANNELLISTINGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_LISTINGMODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_LISTINGMODIFIEDDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [LISTINGMODIFIEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_LISTINGMODIFIEDDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_LISTINGMODIFIEDDATETIMETZID]  DEFAULT ((37001)) FOR [LISTINGMODIFIEDDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_PROCESSED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_PROCESSED]  DEFAULT ((0)) FOR [PROCESSED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_STATUSDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_STATUSDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [STATUSDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_STATUSDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_STATUSDATETIMETZID]  DEFAULT ((37001)) FOR [STATUSDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLISTINGSTATUSLOG_STATUSMESSAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLISTINGSTATUSLOG] ADD  CONSTRAINT [DF_RETAILLISTINGSTATUSLOG_STATUSMESSAGE]  DEFAULT ('') FOR [STATUSMESSAGE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLISTINGSTATUSLOG] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOG]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOG](
[CODEUNIT] [nvarchar](100) NOT NULL,
[DURATIONINMILLISEC] [int] NOT NULL,
[LOGDATE] [date] NOT NULL,
[LOGLEVEL] [int] NOT NULL,
[LOGSTRING] [nvarchar](max) NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[RETAILLOGID] [bigint] NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1372356043_-1275116490] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[RETAILLOGID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILLOG_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_CODEUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_CODEUNIT]  DEFAULT ('') FOR [CODEUNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_DURATIONINMILLISEC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_DURATIONINMILLISEC]  DEFAULT ((0)) FOR [DURATIONINMILLISEC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_LOGDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_LOGDATE]  DEFAULT ('1900-01-01') FOR [LOGDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_LOGLEVEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_LOGLEVEL]  DEFAULT ((0)) FOR [LOGLEVEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_RETAILLOGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_RETAILLOGID]  DEFAULT ((0)) FOR [RETAILLOGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOG_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOG] ADD  CONSTRAINT [DF_RETAILLOG_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOG] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYCARD]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYCARD](
[RECID] [bigint] NOT NULL,
[CARDNUMBER] [nvarchar](30) NOT NULL,
[CARDTENDERTYPE] [int] NOT NULL,
[PARTY] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_162050765_-700086456] PRIMARY KEY CLUSTERED 
(
[CARDNUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARD_CARDNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARD] ADD  CONSTRAINT [DF_RETAILLOYALTYCARD_CARDNUMBER]  DEFAULT ('') FOR [CARDNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARD_CARDTENDERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARD] ADD  CONSTRAINT [DF_RETAILLOYALTYCARD_CARDTENDERTYPE]  DEFAULT ((0)) FOR [CARDTENDERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARD_PARTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARD] ADD  CONSTRAINT [DF_RETAILLOYALTYCARD_PARTY]  DEFAULT ((0)) FOR [PARTY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYCARD] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYCARDTIER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYCARDTIER](
[RECID] [bigint] NOT NULL,
[AFFILIATION] [bigint] NOT NULL,
[LOYALTYCARD] [bigint] NOT NULL,
[LOYALTYTIER] [bigint] NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1091320793_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARDTIER_AFFILIATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARDTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYCARDTIER_AFFILIATION]  DEFAULT ((0)) FOR [AFFILIATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARDTIER_LOYALTYCARD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARDTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYCARDTIER_LOYALTYCARD]  DEFAULT ((0)) FOR [LOYALTYCARD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARDTIER_LOYALTYTIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARDTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYCARDTIER_LOYALTYTIER]  DEFAULT ((0)) FOR [LOYALTYTIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARDTIER_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARDTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYCARDTIER_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYCARDTIER_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYCARDTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYCARDTIER_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYCARDTIER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYEARNSCHEMELINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE](
[RECID] [bigint] NOT NULL,
[FROMACTIVITYAMOUNTCURRENCY] [nvarchar](3) NOT NULL,
[FROMACTIVITYAMOUNTQTY] [numeric](32, 16) NOT NULL,
[FROMACTIVITYRETAILGROUPMEMBERLINE] [bigint] NOT NULL,
[FROMACTIVITYTYPE] [int] NOT NULL,
[LOYALTYSCHEME] [bigint] NOT NULL,
[LOYALTYTIER] [bigint] NOT NULL,
[TOREWARDPOINT] [bigint] NOT NULL,
[TOREWARDPOINTAMOUNTQTY] [numeric](32, 16) NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-818822738_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYAMOUNTCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYAMOUNTCURRENCY]  DEFAULT ('') FOR [FROMACTIVITYAMOUNTCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYAMOUNTQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYAMOUNTQTY]  DEFAULT ((0)) FOR [FROMACTIVITYAMOUNTQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYRETAILGROUPMEMBERLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYRETAILGROUPMEMBERLINE]  DEFAULT ((0)) FOR [FROMACTIVITYRETAILGROUPMEMBERLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_FROMACTIVITYTYPE]  DEFAULT ((0)) FOR [FROMACTIVITYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_LOYALTYSCHEME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_LOYALTYSCHEME]  DEFAULT ((0)) FOR [LOYALTYSCHEME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_LOYALTYTIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_LOYALTYTIER]  DEFAULT ((0)) FOR [LOYALTYTIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_TOREWARDPOINT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_TOREWARDPOINT]  DEFAULT ((0)) FOR [TOREWARDPOINT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_TOREWARDPOINTAMOUNTQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_TOREWARDPOINTAMOUNTQTY]  DEFAULT ((0)) FOR [TOREWARDPOINTAMOUNTQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYEARNSCHEMELINE_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYEARNSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYEARNSCHEMELINE_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYEARNSCHEMELINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYREDEEMSCHEMELINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE](
[RECID] [bigint] NOT NULL,
[FROMREWARDPOINT] [bigint] NOT NULL,
[FROMREWARDPOINTAMOUNTQTY] [numeric](32, 16) NOT NULL,
[LOYALTYSCHEME] [bigint] NOT NULL,
[LOYALTYTIER] [bigint] NOT NULL,
[TORETAILGROUPMEMBERLINE] [bigint] NOT NULL,
[TOREWARDAMOUNTCURRENCY] [nvarchar](3) NOT NULL,
[TOREWARDAMOUNTQTY] [numeric](32, 16) NOT NULL,
[TOREWARDTYPE] [int] NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1369333272_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_FROMREWARDPOINT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_FROMREWARDPOINT]  DEFAULT ((0)) FOR [FROMREWARDPOINT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_FROMREWARDPOINTAMOUNTQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_FROMREWARDPOINTAMOUNTQTY]  DEFAULT ((0)) FOR [FROMREWARDPOINTAMOUNTQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_LOYALTYSCHEME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_LOYALTYSCHEME]  DEFAULT ((0)) FOR [LOYALTYSCHEME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_LOYALTYTIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_LOYALTYTIER]  DEFAULT ((0)) FOR [LOYALTYTIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_TORETAILGROUPMEMBERLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_TORETAILGROUPMEMBERLINE]  DEFAULT ((0)) FOR [TORETAILGROUPMEMBERLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_TOREWARDAMOUNTCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_TOREWARDAMOUNTCURRENCY]  DEFAULT ('') FOR [TOREWARDAMOUNTCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_TOREWARDAMOUNTQTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_TOREWARDAMOUNTQTY]  DEFAULT ((0)) FOR [TOREWARDAMOUNTQTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_TOREWARDTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_TOREWARDTYPE]  DEFAULT ((0)) FOR [TOREWARDTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREDEEMSCHEMELINE_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREDEEMSCHEMELINE] ADD  CONSTRAINT [DF_RETAILLOYALTYREDEEMSCHEMELINE_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYREDEEMSCHEMELINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYREWARDPOINT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYREWARDPOINT](
[RECID] [bigint] NOT NULL,
[EXPIRATIONTIMEUNIT] [int] NOT NULL,
[EXPIRATIONTIMEVALUE] [int] NOT NULL,
[REDEEMABLE] [int] NOT NULL,
[REDEEMRANKING] [int] NOT NULL,
[REWARDPOINTCURRENCY] [nvarchar](3) NOT NULL,
[REWARDPOINTID] [nvarchar](64) NOT NULL,
[REWARDPOINTTYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_493823852_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_493823852_315656331] UNIQUE NONCLUSTERED 
(
[REWARDPOINTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_EXPIRATIONTIMEUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_EXPIRATIONTIMEUNIT]  DEFAULT ((0)) FOR [EXPIRATIONTIMEUNIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_EXPIRATIONTIMEVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_EXPIRATIONTIMEVALUE]  DEFAULT ((0)) FOR [EXPIRATIONTIMEVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_REDEEMABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_REDEEMABLE]  DEFAULT ((0)) FOR [REDEEMABLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_REDEEMRANKING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_REDEEMRANKING]  DEFAULT ((0)) FOR [REDEEMRANKING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_REWARDPOINTCURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_REWARDPOINTCURRENCY]  DEFAULT ('') FOR [REWARDPOINTCURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_REWARDPOINTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_REWARDPOINTID]  DEFAULT ('') FOR [REWARDPOINTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINT_REWARDPOINTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINT] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINT_REWARDPOINTTYPE]  DEFAULT ((0)) FOR [REWARDPOINTTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYREWARDPOINT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYREWARDPOINTTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYREWARDPOINTTRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[REWARDPOINT] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1988105865_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1988105865_1050693241] UNIQUE NONCLUSTERED 
(
[LANGUAGEID] ASC,
[REWARDPOINT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINTTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINTTRANSLATION] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINTTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINTTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINTTRANSLATION] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINTTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYREWARDPOINTTRANSLATION_REWARDPOINT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYREWARDPOINTTRANSLATION] ADD  CONSTRAINT [DF_RETAILLOYALTYREWARDPOINTTRANSLATION_REWARDPOINT]  DEFAULT ((0)) FOR [REWARDPOINT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYREWARDPOINTTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYSCHEME]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYSCHEME](
[RECID] [bigint] NOT NULL,
[AFFILIATION] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[LOYALTYSCHEMEID] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1146749838_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1146749838_-1598981990] UNIQUE NONCLUSTERED 
(
[LOYALTYSCHEMEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEME_AFFILIATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEME] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEME_AFFILIATION]  DEFAULT ((0)) FOR [AFFILIATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEME_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEME] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEME_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEME_LOYALTYSCHEMEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEME] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEME_LOYALTYSCHEMEID]  DEFAULT ('') FOR [LOYALTYSCHEMEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYSCHEME] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYSCHEMECHANNEL]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYSCHEMECHANNEL](
[RECID] [bigint] NOT NULL,
[LOYALTYSCHEME] [bigint] NOT NULL,
[OMHIERARCHYTYPE] [bigint] NOT NULL,
[OMINTERNALORGANIZATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-836280753_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-836280753_-1434205541] UNIQUE NONCLUSTERED 
(
[LOYALTYSCHEME] ASC,
[OMINTERNALORGANIZATION] ASC,
[OMHIERARCHYTYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEMECHANNEL_LOYALTYSCHEME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEMECHANNEL] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEMECHANNEL_LOYALTYSCHEME]  DEFAULT ((0)) FOR [LOYALTYSCHEME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEMECHANNEL_OMHIERARCHYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEMECHANNEL] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEMECHANNEL_OMHIERARCHYTYPE]  DEFAULT ((0)) FOR [OMHIERARCHYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEMECHANNEL_OMINTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEMECHANNEL] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEMECHANNEL_OMINTERNALORGANIZATION]  DEFAULT ((0)) FOR [OMINTERNALORGANIZATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYSCHEMECHANNEL] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYSCHEMECHANNELEXPLODED]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYSCHEMECHANNELEXPLODED](
[RECID] [bigint] NOT NULL,
[LOYALTYSCHEME] [bigint] NOT NULL,
[OMOPERATINGUNIT] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-539412674_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-539412674_-1453058155] UNIQUE NONCLUSTERED 
(
[OMOPERATINGUNIT] ASC,
[LOYALTYSCHEME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEMECHANNELEXPLODED_LOYALTYSCHEME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEMECHANNELEXPLODED] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEMECHANNELEXPLODED_LOYALTYSCHEME]  DEFAULT ((0)) FOR [LOYALTYSCHEME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYSCHEMECHANNELEXPLODED_OMOPERATINGUNIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYSCHEMECHANNELEXPLODED] ADD  CONSTRAINT [DF_RETAILLOYALTYSCHEMECHANNELEXPLODED_OMOPERATINGUNIT]  DEFAULT ((0)) FOR [OMOPERATINGUNIT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYSCHEMECHANNELEXPLODED] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYTIER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYTIER](
[RECID] [bigint] NOT NULL,
[AFFILIATION] [bigint] NOT NULL,
[TIERID] [nvarchar](64) NOT NULL,
[TIERLEVEL] [numeric](32, 16) NOT NULL,
[VALIDDATEINTERVAL] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1384088785_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1384088785_-1841329999] UNIQUE NONCLUSTERED 
(
[AFFILIATION] ASC,
[TIERLEVEL] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1384088785_-2103951646] UNIQUE NONCLUSTERED 
(
[AFFILIATION] ASC,
[TIERID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIER_AFFILIATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYTIER_AFFILIATION]  DEFAULT ((0)) FOR [AFFILIATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIER_TIERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYTIER_TIERID]  DEFAULT ('') FOR [TIERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIER_TIERLEVEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYTIER_TIERLEVEL]  DEFAULT ((0)) FOR [TIERLEVEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIER_VALIDDATEINTERVAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIER] ADD  CONSTRAINT [DF_RETAILLOYALTYTIER_VALIDDATEINTERVAL]  DEFAULT ('') FOR [VALIDDATEINTERVAL]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYTIER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILLOYALTYTIERTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILLOYALTYTIERTRANSLATION](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[LOYALTYTIER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_822357336_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_822357336_-1167379206] UNIQUE NONCLUSTERED 
(
[LANGUAGEID] ASC,
[LOYALTYTIER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIERTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIERTRANSLATION] ADD  CONSTRAINT [DF_RETAILLOYALTYTIERTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIERTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIERTRANSLATION] ADD  CONSTRAINT [DF_RETAILLOYALTYTIERTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILLOYALTYTIERTRANSLATION_LOYALTYTIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILLOYALTYTIERTRANSLATION] ADD  CONSTRAINT [DF_RETAILLOYALTYTIERTRANSLATION_LOYALTYTIER]  DEFAULT ((0)) FOR [LOYALTYTIER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILLOYALTYTIERTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILMIXANDMATCHLINEGROUPS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILMIXANDMATCHLINEGROUPS](
[RECID] [bigint] NOT NULL,
[DISCOUNTLINECOLORID] [int] NOT NULL,
[MIXANDMATCHID] [nvarchar](20) NOT NULL,
[MIXANDMATCHLINEGROUP] [nvarchar](10) NOT NULL,
[NUMBEROFITEMSNEEDED] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_149219285_708740483] PRIMARY KEY CLUSTERED 
(
[MIXANDMATCHID] ASC,
[MIXANDMATCHLINEGROUP] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMIXANDMATCHLINEGROUPS_DISCOUNTLINECOLORID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMIXANDMATCHLINEGROUPS] ADD  CONSTRAINT [DF_RETAILMIXANDMATCHLINEGROUPS_DISCOUNTLINECOLORID]  DEFAULT ((0)) FOR [DISCOUNTLINECOLORID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMIXANDMATCHLINEGROUPS_MIXANDMATCHID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMIXANDMATCHLINEGROUPS] ADD  CONSTRAINT [DF_RETAILMIXANDMATCHLINEGROUPS_MIXANDMATCHID]  DEFAULT ('') FOR [MIXANDMATCHID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMIXANDMATCHLINEGROUPS_MIXANDMATCHLINEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMIXANDMATCHLINEGROUPS] ADD  CONSTRAINT [DF_RETAILMIXANDMATCHLINEGROUPS_MIXANDMATCHLINEGROUP]  DEFAULT ('') FOR [MIXANDMATCHLINEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMIXANDMATCHLINEGROUPS_NUMBEROFITEMSNEEDED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMIXANDMATCHLINEGROUPS] ADD  CONSTRAINT [DF_RETAILMIXANDMATCHLINEGROUPS_NUMBEROFITEMSNEEDED]  DEFAULT ((0)) FOR [NUMBEROFITEMSNEEDED]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILMIXANDMATCHLINEGROUPS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILMULTIBUYDISCOUNTLINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILMULTIBUYDISCOUNTLINE](
[RECID] [bigint] NOT NULL,
[MULTIBUYID] [nvarchar](40) NOT NULL,
[PRICEDISCPCT] [numeric](32, 16) NOT NULL,
[QTYLOWEST] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-320805805_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-320805805_294269066] UNIQUE NONCLUSTERED 
(
[MULTIBUYID] ASC,
[QTYLOWEST] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMULTIBUYDISCOUNTLINE_MULTIBUYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMULTIBUYDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILMULTIBUYDISCOUNTLINE_MULTIBUYID]  DEFAULT ('') FOR [MULTIBUYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMULTIBUYDISCOUNTLINE_PRICEDISCPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMULTIBUYDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILMULTIBUYDISCOUNTLINE_PRICEDISCPCT]  DEFAULT ((0)) FOR [PRICEDISCPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILMULTIBUYDISCOUNTLINE_QTYLOWEST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILMULTIBUYDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILMULTIBUYDISCOUNTLINE_QTYLOWEST]  DEFAULT ((0)) FOR [QTYLOWEST]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILMULTIBUYDISCOUNTLINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOFFLINEPROFILE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOFFLINEPROFILE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](256) NOT NULL,
[NAME] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1301352601_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1301352601_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINEPROFILE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINEPROFILE] ADD  CONSTRAINT [DF_RETAILOFFLINEPROFILE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINEPROFILE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINEPROFILE] ADD  CONSTRAINT [DF_RETAILOFFLINEPROFILE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOFFLINEPROFILE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOFFLINEPROFILESCOPES]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOFFLINEPROFILESCOPES](
[RECID] [bigint] NOT NULL,
[PROFILEID] [bigint] NOT NULL,
[SCOPEID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1443309648_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINEPROFILESCOPES_PROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINEPROFILESCOPES] ADD  CONSTRAINT [DF_RETAILOFFLINEPROFILESCOPES_PROFILEID]  DEFAULT ((0)) FOR [PROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINEPROFILESCOPES_SCOPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINEPROFILESCOPES] ADD  CONSTRAINT [DF_RETAILOFFLINEPROFILESCOPES_SCOPEID]  DEFAULT ((0)) FOR [SCOPEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOFFLINEPROFILESCOPES] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOFFLINESCOPE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOFFLINESCOPE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](256) NOT NULL,
[LASTSYNCTIME] [datetime] NOT NULL,
[LASTSYNCTIMETZID] [int] NOT NULL,
[SYNCDIRECTION] [int] NOT NULL,
[SYNCFREQUENCY] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1144720460_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1144720460_-1781313101] UNIQUE NONCLUSTERED 
(
[DESCRIPTION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPE] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPE_LASTSYNCTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPE] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPE_LASTSYNCTIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [LASTSYNCTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPE_LASTSYNCTIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPE] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPE_LASTSYNCTIMETZID]  DEFAULT ((37001)) FOR [LASTSYNCTIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPE_SYNCDIRECTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPE] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPE_SYNCDIRECTION]  DEFAULT ((0)) FOR [SYNCDIRECTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPE_SYNCFREQUENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPE] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPE_SYNCFREQUENCY]  DEFAULT ((0)) FOR [SYNCFREQUENCY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOFFLINESCOPE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOFFLINESCOPETABLES]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOFFLINESCOPETABLES](
[RECID] [bigint] NOT NULL,
[SCOPEID] [bigint] NOT NULL,
[SYNCTABLEID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-118421387_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-118421387_-1026021288] UNIQUE NONCLUSTERED 
(
[SYNCTABLEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPETABLES_SCOPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPETABLES] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPETABLES_SCOPEID]  DEFAULT ((0)) FOR [SCOPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINESCOPETABLES_SYNCTABLEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINESCOPETABLES] ADD  CONSTRAINT [DF_RETAILOFFLINESCOPETABLES_SYNCTABLEID]  DEFAULT ((0)) FOR [SYNCTABLEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOFFLINESCOPETABLES] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOFFLINETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOFFLINETABLE](
[RECID] [bigint] NOT NULL,
[TABLENAME] [nvarchar](50) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1221725956_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINETABLE_TABLENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINETABLE] ADD  CONSTRAINT [DF_RETAILOFFLINETABLE_TABLENAME]  DEFAULT ('') FOR [TABLENAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOFFLINETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOFFLINETABLECOLUMNS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOFFLINETABLECOLUMNS](
[RECID] [bigint] NOT NULL,
[SYNCCOLUMNNAME] [nvarchar](40) NOT NULL,
[SYNCTABLE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1599311751_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINETABLECOLUMNS_SYNCCOLUMNNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINETABLECOLUMNS] ADD  CONSTRAINT [DF_RETAILOFFLINETABLECOLUMNS_SYNCCOLUMNNAME]  DEFAULT ('') FOR [SYNCCOLUMNNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOFFLINETABLECOLUMNS_SYNCTABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOFFLINETABLECOLUMNS] ADD  CONSTRAINT [DF_RETAILOFFLINETABLECOLUMNS_SYNCTABLE]  DEFAULT ((0)) FOR [SYNCTABLE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOFFLINETABLECOLUMNS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILONLINECHANNELPUBLISHSTATUS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILONLINECHANNELPUBLISHSTATUS](
[RECID] [bigint] NOT NULL,
[ONLINECHANNEL] [bigint] NOT NULL,
[PUBLISHSTATUS] [int] NOT NULL,
[PUBLISHSTATUSMESSAGE] [nvarchar](max) NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-664677306_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-664677306_1180044546] UNIQUE NONCLUSTERED 
(
[ONLINECHANNEL] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILONLINECHANNELPUBLISHSTATUS_ONLINECHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILONLINECHANNELPUBLISHSTATUS] ADD  CONSTRAINT [DF_RETAILONLINECHANNELPUBLISHSTATUS_ONLINECHANNEL]  DEFAULT ((0)) FOR [ONLINECHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILONLINECHANNELPUBLISHSTATUS_PUBLISHSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILONLINECHANNELPUBLISHSTATUS] ADD  CONSTRAINT [DF_RETAILONLINECHANNELPUBLISHSTATUS_PUBLISHSTATUS]  DEFAULT ((0)) FOR [PUBLISHSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILONLINECHANNELPUBLISHSTATUS_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILONLINECHANNELPUBLISHSTATUS] ADD  CONSTRAINT [DF_RETAILONLINECHANNELPUBLISHSTATUS_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILONLINECHANNELPUBLISHSTATUS_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILONLINECHANNELPUBLISHSTATUS] ADD  CONSTRAINT [DF_RETAILONLINECHANNELPUBLISHSTATUS_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILONLINECHANNELPUBLISHSTATUS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILOPERATIONS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILOPERATIONS](
[RECID] [bigint] NOT NULL,
[CHECKUSERACCESS] [int] NOT NULL,
[OPERATIONID] [int] NOT NULL,
[OPERATIONNAME] [nvarchar](50) NOT NULL,
[PERMISSIONID] [int] NOT NULL,
[PERMISSIONID2] [int] NOT NULL,
[USEROPERATION] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1234623639_-1629766275] PRIMARY KEY CLUSTERED 
(
[OPERATIONID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOPERATIONS_CHECKUSERACCESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOPERATIONS] ADD  CONSTRAINT [DF_RETAILOPERATIONS_CHECKUSERACCESS]  DEFAULT ((0)) FOR [CHECKUSERACCESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOPERATIONS_OPERATIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOPERATIONS] ADD  CONSTRAINT [DF_RETAILOPERATIONS_OPERATIONID]  DEFAULT ((0)) FOR [OPERATIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOPERATIONS_OPERATIONNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOPERATIONS] ADD  CONSTRAINT [DF_RETAILOPERATIONS_OPERATIONNAME]  DEFAULT ('') FOR [OPERATIONNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOPERATIONS_PERMISSIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOPERATIONS] ADD  CONSTRAINT [DF_RETAILOPERATIONS_PERMISSIONID]  DEFAULT ((0)) FOR [PERMISSIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOPERATIONS_PERMISSIONID2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOPERATIONS] ADD  CONSTRAINT [DF_RETAILOPERATIONS_PERMISSIONID2]  DEFAULT ((0)) FOR [PERMISSIONID2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILOPERATIONS_USEROPERATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILOPERATIONS] ADD  CONSTRAINT [DF_RETAILOPERATIONS_USEROPERATION]  DEFAULT ((0)) FOR [USEROPERATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILOPERATIONS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPARAMETERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPARAMETERS](
[RECID] [bigint] NOT NULL,
[AUTOMATICRETURNOFLOYALTYPAYMENT_RU] [int] NOT NULL,
[AWARDPOINTSFORPARTIALREDEMPTION_RU] [int] NOT NULL,
[CANCELLATIONCHARGE] [numeric](32, 16) NOT NULL,
[CANCELLATIONCHARGECODE] [nvarchar](10) NOT NULL,
[DEFAULTCUSTOMERPOSTING] [int] NOT NULL,
[DEFAULTORDERTYPE] [int] NOT NULL,
[DISCOUNTOFFERACTIVITYTYPE] [nvarchar](10) NOT NULL,
[EANLICENSENO] [nvarchar](10) NOT NULL,
[ELECTRONICDELIVERYMODECODE] [nvarchar](10) NOT NULL,
[EXPIRATIONDATE] [int] NOT NULL,
[GIFTCARDITEM] [nvarchar](20) NOT NULL,
[ITEMLABELLASTACTION] [nvarchar](10) NOT NULL,
[ITEMLABELSFORNEGATIVESTOCK] [int] NOT NULL,
[ITEMSALESSTATISTICSON] [int] NOT NULL,
[KEY] [int] NOT NULL,
[MINIMUMDEPOSITFORSALESORDER] [numeric](32, 16) NOT NULL,
[MINIMUMPASSWORDLENGTH] [int] NOT NULL,
[MIXANDMATCHACTIVITYTYPE] [nvarchar](10) NOT NULL,
[MULTIBUYACTIVITYTYPE] [nvarchar](10) NOT NULL,
[PAYMENTSTATISTICS] [int] NOT NULL,
[PICKUPDELIVERYMODECODE] [nvarchar](10) NOT NULL,
[POSTCUSTDISC] [int] NOT NULL,
[POSTINFOCODEDISC] [int] NOT NULL,
[POSTLINEDISC] [int] NOT NULL,
[POSTPERIODICDISC] [int] NOT NULL,
[POSTTOTALDISC] [int] NOT NULL,
[PROCESSGIFTCARDSASPREPAYMENTS_RU] [int] NOT NULL,
[PROCESSRETURNSASINORIGINALSALESHIFT_RU] [int] NOT NULL,
[PROPOSEREFUNDPAYMENTAMOUNT_RU] [int] NOT NULL,
[RECEIPTOPTION] [int] NOT NULL,
[REQUIRENUMERICCHAR] [int] NOT NULL,
[REQUIRESPECIALCHAR] [int] NOT NULL,
[REQUIREUPPERCASE] [int] NOT NULL,
[SHELFLABELLASTACTION] [nvarchar](10) NOT NULL,
[SHIPPINGCHARGECODE] [nvarchar](10) NOT NULL,
[STAFFSTATISTICS] [int] NOT NULL,
[TERMINALSTATISTICS] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1854178713_2053771816] PRIMARY KEY CLUSTERED 
(
[KEY] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_AUTOMATICRETURNOFLOYALTYPAYMENT_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_AUTOMATICRETURNOFLOYALTYPAYMENT_RU]  DEFAULT ((0)) FOR [AUTOMATICRETURNOFLOYALTYPAYMENT_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_AWARDPOINTSFORPARTIALREDEMPTION_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_AWARDPOINTSFORPARTIALREDEMPTION_RU]  DEFAULT ((0)) FOR [AWARDPOINTSFORPARTIALREDEMPTION_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_CANCELLATIONCHARGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_CANCELLATIONCHARGE]  DEFAULT ((0)) FOR [CANCELLATIONCHARGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_CANCELLATIONCHARGECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_CANCELLATIONCHARGECODE]  DEFAULT ('') FOR [CANCELLATIONCHARGECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_DEFAULTCUSTOMERPOSTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_DEFAULTCUSTOMERPOSTING]  DEFAULT ((0)) FOR [DEFAULTCUSTOMERPOSTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_DEFAULTORDERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_DEFAULTORDERTYPE]  DEFAULT ((0)) FOR [DEFAULTORDERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_DISCOUNTOFFERACTIVITYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_DISCOUNTOFFERACTIVITYTYPE]  DEFAULT ('') FOR [DISCOUNTOFFERACTIVITYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_EANLICENSENO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_EANLICENSENO]  DEFAULT ('') FOR [EANLICENSENO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_ELECTRONICDELIVERYMODECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_ELECTRONICDELIVERYMODECODE]  DEFAULT ('') FOR [ELECTRONICDELIVERYMODECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_EXPIRATIONDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_EXPIRATIONDATE]  DEFAULT ((0)) FOR [EXPIRATIONDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_GIFTCARDITEM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_GIFTCARDITEM]  DEFAULT ('') FOR [GIFTCARDITEM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_ITEMLABELLASTACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_ITEMLABELLASTACTION]  DEFAULT ('') FOR [ITEMLABELLASTACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_ITEMLABELSFORNEGATIVESTOCK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_ITEMLABELSFORNEGATIVESTOCK]  DEFAULT ((0)) FOR [ITEMLABELSFORNEGATIVESTOCK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_ITEMSALESSTATISTICSON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_ITEMSALESSTATISTICSON]  DEFAULT ((0)) FOR [ITEMSALESSTATISTICSON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_KEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_KEY]  DEFAULT ((0)) FOR [KEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_MINIMUMDEPOSITFORSALESORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_MINIMUMDEPOSITFORSALESORDER]  DEFAULT ((0)) FOR [MINIMUMDEPOSITFORSALESORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_MINIMUMPASSWORDLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_MINIMUMPASSWORDLENGTH]  DEFAULT ((0)) FOR [MINIMUMPASSWORDLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_MIXANDMATCHACTIVITYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_MIXANDMATCHACTIVITYTYPE]  DEFAULT ('') FOR [MIXANDMATCHACTIVITYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_MULTIBUYACTIVITYTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_MULTIBUYACTIVITYTYPE]  DEFAULT ('') FOR [MULTIBUYACTIVITYTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_PAYMENTSTATISTICS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_PAYMENTSTATISTICS]  DEFAULT ((0)) FOR [PAYMENTSTATISTICS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_PICKUPDELIVERYMODECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_PICKUPDELIVERYMODECODE]  DEFAULT ('') FOR [PICKUPDELIVERYMODECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_POSTCUSTDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_POSTCUSTDISC]  DEFAULT ((0)) FOR [POSTCUSTDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_POSTINFOCODEDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_POSTINFOCODEDISC]  DEFAULT ((0)) FOR [POSTINFOCODEDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_POSTLINEDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_POSTLINEDISC]  DEFAULT ((0)) FOR [POSTLINEDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_POSTPERIODICDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_POSTPERIODICDISC]  DEFAULT ((0)) FOR [POSTPERIODICDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_POSTTOTALDISC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_POSTTOTALDISC]  DEFAULT ((0)) FOR [POSTTOTALDISC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_PROCESSGIFTCARDSASPREPAYMENTS_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_PROCESSGIFTCARDSASPREPAYMENTS_RU]  DEFAULT ((0)) FOR [PROCESSGIFTCARDSASPREPAYMENTS_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_PROCESSRETURNSASINORIGINALSALESHIFT_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_PROCESSRETURNSASINORIGINALSALESHIFT_RU]  DEFAULT ((0)) FOR [PROCESSRETURNSASINORIGINALSALESHIFT_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_PROPOSEREFUNDPAYMENTAMOUNT_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_PROPOSEREFUNDPAYMENTAMOUNT_RU]  DEFAULT ((0)) FOR [PROPOSEREFUNDPAYMENTAMOUNT_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_RECEIPTOPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_RECEIPTOPTION]  DEFAULT ((0)) FOR [RECEIPTOPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_REQUIRENUMERICCHAR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_REQUIRENUMERICCHAR]  DEFAULT ((0)) FOR [REQUIRENUMERICCHAR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_REQUIRESPECIALCHAR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_REQUIRESPECIALCHAR]  DEFAULT ((0)) FOR [REQUIRESPECIALCHAR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_REQUIREUPPERCASE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_REQUIREUPPERCASE]  DEFAULT ((0)) FOR [REQUIREUPPERCASE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_SHELFLABELLASTACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_SHELFLABELLASTACTION]  DEFAULT ('') FOR [SHELFLABELLASTACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_SHIPPINGCHARGECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_SHIPPINGCHARGECODE]  DEFAULT ('') FOR [SHIPPINGCHARGECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_STAFFSTATISTICS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_STAFFSTATISTICS]  DEFAULT ((0)) FOR [STAFFSTATISTICS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPARAMETERS_TERMINALSTATISTICS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPARAMETERS] ADD  CONSTRAINT [DF_RETAILPARAMETERS_TERMINALSTATISTICS]  DEFAULT ((0)) FOR [TERMINALSTATISTICS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPARAMETERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPERIODICDISCOUNT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPERIODICDISCOUNT](
[RECID] [bigint] NOT NULL,
[CONCURRENCYMODE] [int] NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[DATEVALIDATIONTYPE] [int] NOT NULL,
[DESCRIPTION] [nvarchar](max) NULL,
[DISCLAIMER] [nvarchar](max) NULL,
[DISCOUNTPERCENTVALUE] [numeric](32, 16) NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[ISDISCOUNTCODEREQUIRED] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[OFFERID] [nvarchar](20) NOT NULL,
[PERIODICDISCOUNTTYPE] [int] NOT NULL,
[PRICEDISCGROUP] [bigint] NOT NULL,
[STATUS] [int] NOT NULL,
[VALIDATIONPERIODID] [nvarchar](10) NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDTO] [date] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_444360761_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_444360761_1895356525] UNIQUE NONCLUSTERED 
(
[OFFERID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_CONCURRENCYMODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_CONCURRENCYMODE]  DEFAULT ((0)) FOR [CONCURRENCYMODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_DATEVALIDATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_DATEVALIDATIONTYPE]  DEFAULT ((0)) FOR [DATEVALIDATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_DISCOUNTPERCENTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_DISCOUNTPERCENTVALUE]  DEFAULT ((0)) FOR [DISCOUNTPERCENTVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_ISDISCOUNTCODEREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_ISDISCOUNTCODEREQUIRED]  DEFAULT ((0)) FOR [ISDISCOUNTCODEREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_OFFERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_OFFERID]  DEFAULT ('') FOR [OFFERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_PERIODICDISCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_PERIODICDISCOUNTTYPE]  DEFAULT ((0)) FOR [PERIODICDISCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_PRICEDISCGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_PRICEDISCGROUP]  DEFAULT ((0)) FOR [PRICEDISCGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_VALIDATIONPERIODID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_VALIDATIONPERIODID]  DEFAULT ('') FOR [VALIDATIONPERIODID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNT_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNT] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNT_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPERIODICDISCOUNT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPERIODICDISCOUNTLINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPERIODICDISCOUNTLINE](
[RECID] [bigint] NOT NULL,
[DISCOUNTPERCENTORVALUE] [numeric](32, 16) NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[ISDISCOUNTCODEREQUIRED] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[OFFERID] [nvarchar](20) NOT NULL,
[RETAILGROUPMEMBERLINE] [bigint] NOT NULL,
[STATUS] [int] NOT NULL,
[UNITOFMEASURE] [bigint] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2095525985_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2095525985_1217888543] UNIQUE NONCLUSTERED 
(
[OFFERID] ASC,
[LINENUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2095525985_-470159237] UNIQUE NONCLUSTERED 
(
[RETAILGROUPMEMBERLINE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_DISCOUNTPERCENTORVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_DISCOUNTPERCENTORVALUE]  DEFAULT ((0)) FOR [DISCOUNTPERCENTORVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_ISDISCOUNTCODEREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_ISDISCOUNTCODEREQUIRED]  DEFAULT ((0)) FOR [ISDISCOUNTCODEREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_OFFERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_OFFERID]  DEFAULT ('') FOR [OFFERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_RETAILGROUPMEMBERLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_RETAILGROUPMEMBERLINE]  DEFAULT ((0)) FOR [RETAILGROUPMEMBERLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERIODICDISCOUNTLINE_UNITOFMEASURE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERIODICDISCOUNTLINE] ADD  CONSTRAINT [DF_RETAILPERIODICDISCOUNTLINE_UNITOFMEASURE]  DEFAULT ((0)) FOR [UNITOFMEASURE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPERIODICDISCOUNTLINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPERMISSIONS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPERMISSIONS](
[RECID] [bigint] NOT NULL,
[PERMISSIONID] [int] NOT NULL,
[PERMISSIONNAME] [nvarchar](100) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-191668477_-407734873] PRIMARY KEY CLUSTERED 
(
[PERMISSIONID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERMISSIONS_PERMISSIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERMISSIONS] ADD  CONSTRAINT [DF_RETAILPERMISSIONS_PERMISSIONID]  DEFAULT ((0)) FOR [PERMISSIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPERMISSIONS_PERMISSIONNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPERMISSIONS] ADD  CONSTRAINT [DF_RETAILPERMISSIONS_PERMISSIONNAME]  DEFAULT ('') FOR [PERMISSIONNAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPERMISSIONS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSBATCHACCOUNTTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS](
[ACCOUNTNUM] [nvarchar](10) NOT NULL,
[ACCOUNTTYPE] [int] NOT NULL,
[AMOUNT] [numeric](32, 16) NOT NULL,
[BATCHID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[REPLICATIONCOUNTER] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2072456596_1536653555] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[BATCHID] ASC,
[ACCOUNTNUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILPOSBATCHACCOUNTTRANS_REPLICATIONCOUNTER] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_ACCOUNTNUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_ACCOUNTNUM]  DEFAULT ('') FOR [ACCOUNTNUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_ACCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_ACCOUNTTYPE]  DEFAULT ((0)) FOR [ACCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_BATCHID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_BATCHID]  DEFAULT ((0)) FOR [BATCHID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHACCOUNTTRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHACCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHACCOUNTTRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSBATCHACCOUNTTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSBATCHTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSBATCHTABLE](
[BATCHID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CLOSEDATE] [date] NOT NULL,
[CLOSEDATETIMEUTC] [datetime] NOT NULL,
[CLOSEDATETIMEUTCTZID] [int] NOT NULL,
[CLOSEDATTERMINAL] [nvarchar](10) NOT NULL,
[CLOSETIME] [int] NOT NULL,
[CUSTOMERSCOUNT] [int] NOT NULL,
[DISCOUNTTOTAL] [numeric](32, 16) NOT NULL,
[LOGONSCOUNT] [int] NOT NULL,
[NOSALECOUNT] [int] NOT NULL,
[PAIDTOACCOUNTTOTAL] [numeric](32, 16) NOT NULL,
[POSTED] [int] NOT NULL,
[REPLICATIONCOUNTER] [int] IDENTITY(1,1) NOT NULL,
[RETURNSTOTAL] [numeric](32, 16) NOT NULL,
[ROUNDEDAMOUNTTOTAL] [numeric](32, 16) NOT NULL,
[SALESCOUNT] [int] NOT NULL,
[SALESTOTAL] [numeric](32, 16) NOT NULL,
[STAFFID] [nvarchar](25) NOT NULL,
[STARTDATE] [date] NOT NULL,
[STARTDATETIMEUTC] [datetime] NOT NULL,
[STARTDATETIMEUTCTZID] [int] NOT NULL,
[STARTTIME] [int] NOT NULL,
[STATUS] [int] NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TAXTOTAL] [numeric](32, 16) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONSCOUNT] [int] NOT NULL,
[VOIDSCOUNT] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1033447763_133955128] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[BATCHID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILPOSBATCHTABLE_REPLICATIONCOUNTER] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_BATCHID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_BATCHID]  DEFAULT ((0)) FOR [BATCHID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CLOSEDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CLOSEDATE]  DEFAULT ('1900-01-01') FOR [CLOSEDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CLOSEDATETIMEUTC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CLOSEDATETIMEUTC]  DEFAULT ('1900-01-01 00:00:00.000') FOR [CLOSEDATETIMEUTC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CLOSEDATETIMEUTCTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CLOSEDATETIMEUTCTZID]  DEFAULT ((37001)) FOR [CLOSEDATETIMEUTCTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CLOSEDATTERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CLOSEDATTERMINAL]  DEFAULT ('') FOR [CLOSEDATTERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CLOSETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CLOSETIME]  DEFAULT ((0)) FOR [CLOSETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_CUSTOMERSCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_CUSTOMERSCOUNT]  DEFAULT ((0)) FOR [CUSTOMERSCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_DISCOUNTTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_DISCOUNTTOTAL]  DEFAULT ((0)) FOR [DISCOUNTTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_LOGONSCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_LOGONSCOUNT]  DEFAULT ((0)) FOR [LOGONSCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_NOSALECOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_NOSALECOUNT]  DEFAULT ((0)) FOR [NOSALECOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_PAIDTOACCOUNTTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_PAIDTOACCOUNTTOTAL]  DEFAULT ((0)) FOR [PAIDTOACCOUNTTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_POSTED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_POSTED]  DEFAULT ((0)) FOR [POSTED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_RETURNSTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_RETURNSTOTAL]  DEFAULT ((0)) FOR [RETURNSTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_ROUNDEDAMOUNTTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_ROUNDEDAMOUNTTOTAL]  DEFAULT ((0)) FOR [ROUNDEDAMOUNTTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_SALESCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_SALESCOUNT]  DEFAULT ((0)) FOR [SALESCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_SALESTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_SALESTOTAL]  DEFAULT ((0)) FOR [SALESTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STAFFID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STAFFID]  DEFAULT ('') FOR [STAFFID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STARTDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STARTDATE]  DEFAULT ('1900-01-01') FOR [STARTDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STARTDATETIMEUTC]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STARTDATETIMEUTC]  DEFAULT ('1900-01-01 00:00:00.000') FOR [STARTDATETIMEUTC]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STARTDATETIMEUTCTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STARTDATETIMEUTCTZID]  DEFAULT ((37001)) FOR [STARTDATETIMEUTCTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STARTTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STARTTIME]  DEFAULT ((0)) FOR [STARTTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_TAXTOTAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_TAXTOTAL]  DEFAULT ((0)) FOR [TAXTOTAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_TRANSACTIONSCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_TRANSACTIONSCOUNT]  DEFAULT ((0)) FOR [TRANSACTIONSCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTABLE_VOIDSCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTABLE] ADD  CONSTRAINT [DF_RETAILPOSBATCHTABLE_VOIDSCOUNT]  DEFAULT ((0)) FOR [VOIDSCOUNT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSBATCHTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSBATCHTENDERTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSBATCHTENDERTRANS](
[ADDTOTENDERAMOUNT] [numeric](32, 16) NOT NULL,
[ADDTOTENDERAMOUNTCUR] [numeric](32, 16) NOT NULL,
[BANKDROPAMOUNT] [numeric](32, 16) NOT NULL,
[BANKDROPAMOUNTCUR] [numeric](32, 16) NOT NULL,
[BATCHID] [bigint] NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[CHANGEAMOUNT] [numeric](32, 16) NOT NULL,
[CHANGEAMOUNTCUR] [numeric](32, 16) NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[COUNT] [int] NOT NULL,
[COUNTINGREQUIRED] [int] NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[DECLARETENDERAMOUNT] [numeric](32, 16) NOT NULL,
[DECLARETENDERAMOUNTCUR] [numeric](32, 16) NOT NULL,
[REMOVETENDERAMOUNT] [numeric](32, 16) NOT NULL,
[REMOVETENDERAMOUNTCUR] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTER] [int] IDENTITY(1,1) NOT NULL,
[SAFEDROPAMOUNT] [numeric](32, 16) NOT NULL,
[SAFEDROPAMOUNTCUR] [numeric](32, 16) NOT NULL,
[STARTINGAMOUNT] [numeric](32, 16) NOT NULL,
[STARTINGAMOUNTCUR] [numeric](32, 16) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TENDEREDAMOUNT] [numeric](32, 16) NOT NULL,
[TENDEREDAMOUNTCUR] [numeric](32, 16) NOT NULL,
[TENDERTYPEID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1239242545_-1990270058] PRIMARY KEY CLUSTERED 
(
[CURRENCY] ASC,
[CARDTYPEID] ASC,
[STOREID] ASC,
[TERMINALID] ASC,
[BATCHID] ASC,
[TENDERTYPEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILPOSBATCHTENDERTRANS_REPLICATIONCOUNTER] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_ADDTOTENDERAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_ADDTOTENDERAMOUNT]  DEFAULT ((0)) FOR [ADDTOTENDERAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_ADDTOTENDERAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_ADDTOTENDERAMOUNTCUR]  DEFAULT ((0)) FOR [ADDTOTENDERAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_BANKDROPAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_BANKDROPAMOUNT]  DEFAULT ((0)) FOR [BANKDROPAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_BANKDROPAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_BANKDROPAMOUNTCUR]  DEFAULT ((0)) FOR [BANKDROPAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_BATCHID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_BATCHID]  DEFAULT ((0)) FOR [BATCHID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_CHANGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_CHANGEAMOUNT]  DEFAULT ((0)) FOR [CHANGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_CHANGEAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_CHANGEAMOUNTCUR]  DEFAULT ((0)) FOR [CHANGEAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_COUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_COUNT]  DEFAULT ((0)) FOR [COUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_COUNTINGREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_COUNTINGREQUIRED]  DEFAULT ((0)) FOR [COUNTINGREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_DECLARETENDERAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_DECLARETENDERAMOUNT]  DEFAULT ((0)) FOR [DECLARETENDERAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_DECLARETENDERAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_DECLARETENDERAMOUNTCUR]  DEFAULT ((0)) FOR [DECLARETENDERAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_REMOVETENDERAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_REMOVETENDERAMOUNT]  DEFAULT ((0)) FOR [REMOVETENDERAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_REMOVETENDERAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_REMOVETENDERAMOUNTCUR]  DEFAULT ((0)) FOR [REMOVETENDERAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_SAFEDROPAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_SAFEDROPAMOUNT]  DEFAULT ((0)) FOR [SAFEDROPAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_SAFEDROPAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_SAFEDROPAMOUNTCUR]  DEFAULT ((0)) FOR [SAFEDROPAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_STARTINGAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_STARTINGAMOUNT]  DEFAULT ((0)) FOR [STARTINGAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_STARTINGAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_STARTINGAMOUNTCUR]  DEFAULT ((0)) FOR [STARTINGAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_TENDEREDAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_TENDEREDAMOUNT]  DEFAULT ((0)) FOR [TENDEREDAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_TENDEREDAMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_TENDEREDAMOUNTCUR]  DEFAULT ((0)) FOR [TENDEREDAMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_TENDERTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_TENDERTYPEID]  DEFAULT ('') FOR [TENDERTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSBATCHTENDERTRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSBATCHTENDERTRANS] ADD  CONSTRAINT [DF_RETAILPOSBATCHTENDERTRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSBATCHTENDERTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSITIONPOSPERMISSION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSITIONPOSPERMISSION](
[RECID] [bigint] NOT NULL,
[ALLOWBLINDCLOSE] [int] NOT NULL,
[ALLOWCHANGENOVOID] [int] NOT NULL,
[ALLOWCHANGEPERIPHERALSTATION] [int] NOT NULL,
[ALLOWCREATEORDER] [int] NOT NULL,
[ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU] [int] NOT NULL,
[ALLOWEDITORDER] [int] NOT NULL,
[ALLOWFLOATINGTENDERDECLARATION] [int] NOT NULL,
[ALLOWKITDISASSEMBLY] [int] NOT NULL,
[ALLOWMULTIPLELOGINS] [int] NOT NULL,
[ALLOWMULTIPLESHIFTLOGON] [int] NOT NULL,
[ALLOWNOTSAMEDATERETURN_RU] [int] NOT NULL,
[ALLOWOPENDRAWERONLY] [int] NOT NULL,
[ALLOWPASSWORDCHANGE] [int] NOT NULL,
[ALLOWPRICEOVERRIDE] [int] NOT NULL,
[ALLOWRESETPASSWORD] [int] NOT NULL,
[ALLOWRETRIEVEORDER] [int] NOT NULL,
[ALLOWRETURNOFNONRETURNABLEITEM_RU] [int] NOT NULL,
[ALLOWSALESTAXCHANGE] [int] NOT NULL,
[ALLOWTENDERDECLARATION] [int] NOT NULL,
[ALLOWTRANSACTIONSUSPENSION] [int] NOT NULL,
[ALLOWTRANSACTIONVOIDING] [int] NOT NULL,
[ALLOWXREPORTPRINTING] [int] NOT NULL,
[ALLOWZREPORTPRINTING] [int] NOT NULL,
[MANAGEDEVICE] [int] NOT NULL,
[MANAGERPRIVILEGES] [int] NOT NULL,
[MAXIMUMDISCOUNTPCT] [numeric](32, 16) NOT NULL,
[MAXLINEDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[MAXLINERETURNAMOUNT] [numeric](32, 16) NOT NULL,
[MAXTOTALDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[MAXTOTALDISCOUNTPCT] [numeric](32, 16) NOT NULL,
[MAXTOTALRETURNAMOUNT] [numeric](32, 16) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[POSITION] [bigint] NOT NULL,
[POSPERMISSIONGROUP] [bigint] NOT NULL,
[USEHANDHELD] [int] NOT NULL,
[VIEWTIMECLOCKENTRIES] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_562388273_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_562388273_-1074520080] UNIQUE NONCLUSTERED 
(
[POSITION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWBLINDCLOSE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWBLINDCLOSE]  DEFAULT ((0)) FOR [ALLOWBLINDCLOSE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWCHANGENOVOID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWCHANGENOVOID]  DEFAULT ((0)) FOR [ALLOWCHANGENOVOID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWCHANGEPERIPHERALSTATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWCHANGEPERIPHERALSTATION]  DEFAULT ((0)) FOR [ALLOWCHANGEPERIPHERALSTATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWCREATEORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWCREATEORDER]  DEFAULT ((0)) FOR [ALLOWCREATEORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU]  DEFAULT ((0)) FOR [ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWEDITORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWEDITORDER]  DEFAULT ((0)) FOR [ALLOWEDITORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWFLOATINGTENDERDECLARATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWFLOATINGTENDERDECLARATION]  DEFAULT ((0)) FOR [ALLOWFLOATINGTENDERDECLARATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWKITDISASSEMBLY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWKITDISASSEMBLY]  DEFAULT ((0)) FOR [ALLOWKITDISASSEMBLY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWMULTIPLELOGINS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWMULTIPLELOGINS]  DEFAULT ((0)) FOR [ALLOWMULTIPLELOGINS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWMULTIPLESHIFTLOGON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWMULTIPLESHIFTLOGON]  DEFAULT ((0)) FOR [ALLOWMULTIPLESHIFTLOGON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWNOTSAMEDATERETURN_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWNOTSAMEDATERETURN_RU]  DEFAULT ((0)) FOR [ALLOWNOTSAMEDATERETURN_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWOPENDRAWERONLY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWOPENDRAWERONLY]  DEFAULT ((0)) FOR [ALLOWOPENDRAWERONLY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWPASSWORDCHANGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWPASSWORDCHANGE]  DEFAULT ((0)) FOR [ALLOWPASSWORDCHANGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWPRICEOVERRIDE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWPRICEOVERRIDE]  DEFAULT ((0)) FOR [ALLOWPRICEOVERRIDE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWRESETPASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWRESETPASSWORD]  DEFAULT ((0)) FOR [ALLOWRESETPASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWRETRIEVEORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWRETRIEVEORDER]  DEFAULT ((0)) FOR [ALLOWRETRIEVEORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWRETURNOFNONRETURNABLEITEM_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWRETURNOFNONRETURNABLEITEM_RU]  DEFAULT ((0)) FOR [ALLOWRETURNOFNONRETURNABLEITEM_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWSALESTAXCHANGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWSALESTAXCHANGE]  DEFAULT ((0)) FOR [ALLOWSALESTAXCHANGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWTENDERDECLARATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWTENDERDECLARATION]  DEFAULT ((0)) FOR [ALLOWTENDERDECLARATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWTRANSACTIONSUSPENSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWTRANSACTIONSUSPENSION]  DEFAULT ((0)) FOR [ALLOWTRANSACTIONSUSPENSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWTRANSACTIONVOIDING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWTRANSACTIONVOIDING]  DEFAULT ((0)) FOR [ALLOWTRANSACTIONVOIDING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWXREPORTPRINTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWXREPORTPRINTING]  DEFAULT ((0)) FOR [ALLOWXREPORTPRINTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_ALLOWZREPORTPRINTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_ALLOWZREPORTPRINTING]  DEFAULT ((0)) FOR [ALLOWZREPORTPRINTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MANAGEDEVICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MANAGEDEVICE]  DEFAULT ((0)) FOR [MANAGEDEVICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MANAGERPRIVILEGES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MANAGERPRIVILEGES]  DEFAULT ((0)) FOR [MANAGERPRIVILEGES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MAXIMUMDISCOUNTPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MAXIMUMDISCOUNTPCT]  DEFAULT ((0)) FOR [MAXIMUMDISCOUNTPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MAXLINEDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MAXLINEDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [MAXLINEDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MAXLINERETURNAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MAXLINERETURNAMOUNT]  DEFAULT ((0)) FOR [MAXLINERETURNAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MAXTOTALDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MAXTOTALDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [MAXTOTALDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MAXTOTALDISCOUNTPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MAXTOTALDISCOUNTPCT]  DEFAULT ((0)) FOR [MAXTOTALDISCOUNTPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_MAXTOTALRETURNAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_MAXTOTALRETURNAMOUNT]  DEFAULT ((0)) FOR [MAXTOTALRETURNAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_POSITION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_POSITION]  DEFAULT ((0)) FOR [POSITION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_POSPERMISSIONGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_POSPERMISSIONGROUP]  DEFAULT ((0)) FOR [POSPERMISSIONGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_USEHANDHELD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_USEHANDHELD]  DEFAULT ((0)) FOR [USEHANDHELD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSITIONPOSPERMISSION_VIEWTIMECLOCKENTRIES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSITIONPOSPERMISSION] ADD  CONSTRAINT [DF_RETAILPOSITIONPOSPERMISSION_VIEWTIMECLOCKENTRIES]  DEFAULT ((0)) FOR [VIEWTIMECLOCKENTRIES]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSITIONPOSPERMISSION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSPERMISSIONGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSPERMISSIONGROUP](
[RECID] [bigint] NOT NULL,
[ALLOWBLINDCLOSE] [int] NOT NULL,
[ALLOWCHANGENOVOID] [int] NOT NULL,
[ALLOWCHANGEPERIPHERALSTATION] [int] NOT NULL,
[ALLOWCREATEORDER] [int] NOT NULL,
[ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU] [int] NOT NULL,
[ALLOWEDITORDER] [int] NOT NULL,
[ALLOWFLOATINGTENDERDECLARATION] [int] NOT NULL,
[ALLOWKITDISASSEMBLY] [int] NOT NULL,
[ALLOWMULTIPLELOGINS] [int] NOT NULL,
[ALLOWMULTIPLESHIFTLOGON] [int] NOT NULL,
[ALLOWNOTSAMEDATERETURN_RU] [int] NOT NULL,
[ALLOWOPENDRAWERONLY] [int] NOT NULL,
[ALLOWPASSWORDCHANGE] [int] NOT NULL,
[ALLOWPRICEOVERRIDE] [int] NOT NULL,
[ALLOWRESETPASSWORD] [int] NOT NULL,
[ALLOWRETRIEVEORDER] [int] NOT NULL,
[ALLOWRETURNOFNONRETURNABLEITEM_RU] [int] NOT NULL,
[ALLOWSALESTAXCHANGE] [int] NOT NULL,
[ALLOWTENDERDECLARATION] [int] NOT NULL,
[ALLOWTRANSACTIONSUSPENSION] [int] NOT NULL,
[ALLOWTRANSACTIONVOIDING] [int] NOT NULL,
[ALLOWXREPORTPRINTING] [int] NOT NULL,
[ALLOWZREPORTPRINTING] [int] NOT NULL,
[MANAGEDEVICE] [int] NOT NULL,
[MANAGERPRIVILEGES] [int] NOT NULL,
[MAXIMUMDISCOUNTPCT] [numeric](32, 16) NOT NULL,
[MAXLINEDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[MAXLINERETURNAMOUNT] [numeric](32, 16) NOT NULL,
[MAXTOTALDISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[MAXTOTALDISCOUNTPCT] [numeric](32, 16) NOT NULL,
[MAXTOTALRETURNAMOUNT] [numeric](32, 16) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[POSPERMISSIONGROUPID] [nvarchar](10) NOT NULL,
[USEHANDHELD] [int] NOT NULL,
[VIEWTIMECLOCKENTRIES] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1827980109_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1827980109_-143086023] UNIQUE NONCLUSTERED 
(
[POSPERMISSIONGROUPID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWBLINDCLOSE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWBLINDCLOSE]  DEFAULT ((0)) FOR [ALLOWBLINDCLOSE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWCHANGENOVOID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWCHANGENOVOID]  DEFAULT ((0)) FOR [ALLOWCHANGENOVOID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWCHANGEPERIPHERALSTATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWCHANGEPERIPHERALSTATION]  DEFAULT ((0)) FOR [ALLOWCHANGEPERIPHERALSTATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWCREATEORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWCREATEORDER]  DEFAULT ((0)) FOR [ALLOWCREATEORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU]  DEFAULT ((0)) FOR [ALLOWDIFFERENTPAYMENTMETHODREFUNDS_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWEDITORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWEDITORDER]  DEFAULT ((0)) FOR [ALLOWEDITORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWFLOATINGTENDERDECLARATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWFLOATINGTENDERDECLARATION]  DEFAULT ((0)) FOR [ALLOWFLOATINGTENDERDECLARATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWKITDISASSEMBLY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWKITDISASSEMBLY]  DEFAULT ((0)) FOR [ALLOWKITDISASSEMBLY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWMULTIPLELOGINS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWMULTIPLELOGINS]  DEFAULT ((0)) FOR [ALLOWMULTIPLELOGINS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWMULTIPLESHIFTLOGON]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWMULTIPLESHIFTLOGON]  DEFAULT ((0)) FOR [ALLOWMULTIPLESHIFTLOGON]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWNOTSAMEDATERETURN_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWNOTSAMEDATERETURN_RU]  DEFAULT ((0)) FOR [ALLOWNOTSAMEDATERETURN_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWOPENDRAWERONLY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWOPENDRAWERONLY]  DEFAULT ((0)) FOR [ALLOWOPENDRAWERONLY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWPASSWORDCHANGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWPASSWORDCHANGE]  DEFAULT ((0)) FOR [ALLOWPASSWORDCHANGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWPRICEOVERRIDE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWPRICEOVERRIDE]  DEFAULT ((0)) FOR [ALLOWPRICEOVERRIDE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWRESETPASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWRESETPASSWORD]  DEFAULT ((0)) FOR [ALLOWRESETPASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWRETRIEVEORDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWRETRIEVEORDER]  DEFAULT ((0)) FOR [ALLOWRETRIEVEORDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWRETURNOFNONRETURNABLEITEM_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWRETURNOFNONRETURNABLEITEM_RU]  DEFAULT ((0)) FOR [ALLOWRETURNOFNONRETURNABLEITEM_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWSALESTAXCHANGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWSALESTAXCHANGE]  DEFAULT ((0)) FOR [ALLOWSALESTAXCHANGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWTENDERDECLARATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWTENDERDECLARATION]  DEFAULT ((0)) FOR [ALLOWTENDERDECLARATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWTRANSACTIONSUSPENSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWTRANSACTIONSUSPENSION]  DEFAULT ((0)) FOR [ALLOWTRANSACTIONSUSPENSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWTRANSACTIONVOIDING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWTRANSACTIONVOIDING]  DEFAULT ((0)) FOR [ALLOWTRANSACTIONVOIDING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWXREPORTPRINTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWXREPORTPRINTING]  DEFAULT ((0)) FOR [ALLOWXREPORTPRINTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_ALLOWZREPORTPRINTING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_ALLOWZREPORTPRINTING]  DEFAULT ((0)) FOR [ALLOWZREPORTPRINTING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MANAGEDEVICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MANAGEDEVICE]  DEFAULT ((0)) FOR [MANAGEDEVICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MANAGERPRIVILEGES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MANAGERPRIVILEGES]  DEFAULT ((0)) FOR [MANAGERPRIVILEGES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MAXIMUMDISCOUNTPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MAXIMUMDISCOUNTPCT]  DEFAULT ((0)) FOR [MAXIMUMDISCOUNTPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MAXLINEDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MAXLINEDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [MAXLINEDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MAXLINERETURNAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MAXLINERETURNAMOUNT]  DEFAULT ((0)) FOR [MAXLINERETURNAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MAXTOTALDISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MAXTOTALDISCOUNTAMOUNT]  DEFAULT ((0)) FOR [MAXTOTALDISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MAXTOTALDISCOUNTPCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MAXTOTALDISCOUNTPCT]  DEFAULT ((0)) FOR [MAXTOTALDISCOUNTPCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_MAXTOTALRETURNAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_MAXTOTALRETURNAMOUNT]  DEFAULT ((0)) FOR [MAXTOTALRETURNAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_POSPERMISSIONGROUPID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_POSPERMISSIONGROUPID]  DEFAULT ('') FOR [POSPERMISSIONGROUPID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_USEHANDHELD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_USEHANDHELD]  DEFAULT ((0)) FOR [USEHANDHELD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSPERMISSIONGROUP_VIEWTIMECLOCKENTRIES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILPOSPERMISSIONGROUP_VIEWTIMECLOCKENTRIES]  DEFAULT ((0)) FOR [VIEWTIMECLOCKENTRIES]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSPERMISSIONGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSSEEDDATA]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSSEEDDATA](
[DATATYPE] [int] NOT NULL,
[DATAVALUE] [bigint] NOT NULL,
[STORENUMBER] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1653969084_-308865658] PRIMARY KEY CLUSTERED 
(
[DATATYPE] ASC,
[STORENUMBER] ASC,
[TERMINALID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSSEEDDATA_DATATYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSSEEDDATA] ADD  CONSTRAINT [DF_RETAILPOSSEEDDATA_DATATYPE]  DEFAULT ((0)) FOR [DATATYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSSEEDDATA_DATAVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSSEEDDATA] ADD  CONSTRAINT [DF_RETAILPOSSEEDDATA_DATAVALUE]  DEFAULT ((0)) FOR [DATAVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSSEEDDATA_STORENUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSSEEDDATA] ADD  CONSTRAINT [DF_RETAILPOSSEEDDATA_STORENUMBER]  DEFAULT ('') FOR [STORENUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSSEEDDATA_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSSEEDDATA] ADD  CONSTRAINT [DF_RETAILPOSSEEDDATA_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSSEEDDATA] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPOSTHEME]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPOSTHEME](
[RECID] [bigint] NOT NULL,
[DEVICETYPE] [bigint] NOT NULL,
[NAME] [nvarchar](100) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_955159962_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_955159962_516664720] UNIQUE NONCLUSTERED 
(
[DEVICETYPE] ASC,
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSTHEME_DEVICETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSTHEME] ADD  CONSTRAINT [DF_RETAILPOSTHEME_DEVICETYPE]  DEFAULT ((0)) FOR [DEVICETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPOSTHEME_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPOSTHEME] ADD  CONSTRAINT [DF_RETAILPOSTHEME_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPOSTHEME] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOG]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOG](
[RECID] [bigint] NOT NULL,
[ENABLESNAPSHOT] [int] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[OWNER] [bigint] NOT NULL,
[PUBLISHEDDATETIME] [datetime] NOT NULL,
[PUBLISHEDDATETIMETZID] [int] NOT NULL,
[PUBLISHEDVALIDFROM] [date] NOT NULL,
[PUBLISHEDVALIDTO] [date] NOT NULL,
[STATE] [int] NOT NULL,
[VALIDFROM] [date] NOT NULL,
[VALIDFROMDATETIME] [datetime] NOT NULL,
[VALIDFROMDATETIMETZID] [int] NOT NULL,
[VALIDTO] [date] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[MODIFIEDBY] [nvarchar](8) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1981983829_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1981983829_-162312163] UNIQUE CLUSTERED 
(
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_ENABLESNAPSHOT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_ENABLESNAPSHOT]  DEFAULT ((0)) FOR [ENABLESNAPSHOT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_OWNER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_OWNER]  DEFAULT ((0)) FOR [OWNER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_PUBLISHEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_PUBLISHEDDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [PUBLISHEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_PUBLISHEDDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_PUBLISHEDDATETIMETZID]  DEFAULT ((37001)) FOR [PUBLISHEDDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_PUBLISHEDVALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_PUBLISHEDVALIDFROM]  DEFAULT ('1900-01-01') FOR [PUBLISHEDVALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_PUBLISHEDVALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_PUBLISHEDVALIDTO]  DEFAULT ('1900-01-01') FOR [PUBLISHEDVALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_STATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_STATE]  DEFAULT ((0)) FOR [STATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_VALIDFROM]  DEFAULT ('1900-01-01') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_VALIDFROMDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_VALIDFROMDATETIME]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROMDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_VALIDFROMDATETIMETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_VALIDFROMDATETIMETZID]  DEFAULT ((37001)) FOR [VALIDFROMDATETIMETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_VALIDTO]  DEFAULT ('1900-01-01') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOG_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOG] ADD  CONSTRAINT [DF_RETAILPUBCATALOG_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOG] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOGINTERNALORG]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOGINTERNALORG](
[RECID] [bigint] NOT NULL,
[CATALOG] [bigint] NOT NULL,
[INTERNALORGANIZATION] [bigint] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[ORIGINRECVERSION] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-756910420_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-756910420_102317915] UNIQUE CLUSTERED 
(
[CATALOG] ASC,
[INTERNALORGANIZATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-756910420_-162312163] UNIQUE NONCLUSTERED 
(
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGINTERNALORG_CATALOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGINTERNALORG] ADD  CONSTRAINT [DF_RETAILPUBCATALOGINTERNALORG_CATALOG]  DEFAULT ((0)) FOR [CATALOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGINTERNALORG_INTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGINTERNALORG] ADD  CONSTRAINT [DF_RETAILPUBCATALOGINTERNALORG_INTERNALORGANIZATION]  DEFAULT ((0)) FOR [INTERNALORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGINTERNALORG_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGINTERNALORG] ADD  CONSTRAINT [DF_RETAILPUBCATALOGINTERNALORG_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGINTERNALORG_ORIGINRECVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGINTERNALORG] ADD  CONSTRAINT [DF_RETAILPUBCATALOGINTERNALORG_ORIGINRECVERSION]  DEFAULT ((0)) FOR [ORIGINRECVERSION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOGINTERNALORG] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOGPRODUCT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOGPRODUCT](
[RECID] [bigint] NOT NULL,
[CATALOG] [bigint] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[USEHIERARCHY] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_144266078_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_144266078_1631511146] UNIQUE CLUSTERED 
(
[CATALOG] ASC,
[PRODUCT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_144266078_-162312163] UNIQUE NONCLUSTERED 
(
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCT_CATALOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCT] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCT_CATALOG]  DEFAULT ((0)) FOR [CATALOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCT_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCT] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCT_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCT_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCT] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCT_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCT_USEHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCT] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCT_USEHIERARCHY]  DEFAULT ((0)) FOR [USEHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCT_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCT] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCT_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCT_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCT] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCT_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOGPRODUCT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOGPRODUCTCATEGORY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY](
[RECID] [bigint] NOT NULL,
[CATALOGPRODUCT] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[CATEGORYHIERARCHY] [bigint] NOT NULL,
[INCLUDEEXCLUDETYPE] [int] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_838037498_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_838037498_1588830537] UNIQUE CLUSTERED 
(
[CATALOGPRODUCT] ASC,
[CATEGORY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_CATALOGPRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_CATALOGPRODUCT]  DEFAULT ((0)) FOR [CATALOGPRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_CATEGORYHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_CATEGORYHIERARCHY]  DEFAULT ((0)) FOR [CATEGORYHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_INCLUDEEXCLUDETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_INCLUDEEXCLUDETYPE]  DEFAULT ((0)) FOR [INCLUDEEXCLUDETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTCATEGORY_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTCATEGORY_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOGPRODUCTCATEGORY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOGPRODUCTRELATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATION](
[RECID] [bigint] NOT NULL,
[CATALOGPRODUCT] [bigint] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[PRODUCTRELATIONTYPE] [bigint] NOT NULL,
[RELATEDPRODUCT] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-756004594_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-756004594_-777987643] UNIQUE CLUSTERED 
(
[CATALOGPRODUCT] ASC,
[PRODUCTRELATIONTYPE] ASC,
[RELATEDPRODUCT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-756004594_1082545321] UNIQUE NONCLUSTERED 
(
[CATALOGPRODUCT] ASC,
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATION_CATALOGPRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATION_CATALOGPRODUCT]  DEFAULT ((0)) FOR [CATALOGPRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATION_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATION_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATION_PRODUCTRELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATION_PRODUCTRELATIONTYPE]  DEFAULT ((0)) FOR [PRODUCTRELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATION_RELATEDPRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATION_RELATEDPRODUCT]  DEFAULT ((0)) FOR [RELATEDPRODUCT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOGPRODUCTRELATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION](
[RECID] [bigint] NOT NULL,
[CATALOGPRODUCT] [bigint] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[PRODUCTRELATION] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-348013118_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-348013118_-609989922] UNIQUE CLUSTERED 
(
[CATALOGPRODUCT] ASC,
[PRODUCTRELATION] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-348013118_-162312163] UNIQUE NONCLUSTERED 
(
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION_CATALOGPRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION_CATALOGPRODUCT]  DEFAULT ((0)) FOR [CATALOGPRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION_PRODUCTRELATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION_PRODUCTRELATION]  DEFAULT ((0)) FOR [PRODUCTRELATION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOGPRODUCTRELATIONEXCLUSION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCATALOGTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCATALOGTRANSLATION](
[RECID] [bigint] NOT NULL,
[CATALOG] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](128) NOT NULL,
[FRIENDLYNAME] [nvarchar](60) NOT NULL,
[IMAGE] [nvarchar](1999) NOT NULL,
[LANGUAGE] [nvarchar](7) NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-897518270_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-897518270_-162312163] UNIQUE NONCLUSTERED 
(
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-897518270_-1799725725] UNIQUE NONCLUSTERED 
(
[CATALOG] ASC,
[LANGUAGE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGTRANSLATION_CATALOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGTRANSLATION_CATALOG]  DEFAULT ((0)) FOR [CATALOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGTRANSLATION_FRIENDLYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGTRANSLATION_FRIENDLYNAME]  DEFAULT ('') FOR [FRIENDLYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGTRANSLATION_IMAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGTRANSLATION_IMAGE]  DEFAULT ('') FOR [IMAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGTRANSLATION_LANGUAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGTRANSLATION_LANGUAGE]  DEFAULT ('') FOR [LANGUAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCATALOGTRANSLATION_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCATALOGTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBCATALOGTRANSLATION_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCATALOGTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBCHANNELATTRIBUTE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBCHANNELATTRIBUTE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[ATTRIBUTEVALUE] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1546253985_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1546253985_67495050] UNIQUE NONCLUSTERED 
(
[CHANNEL] ASC,
[ATTRIBUTE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCHANNELATTRIBUTE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCHANNELATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBCHANNELATTRIBUTE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCHANNELATTRIBUTE_ATTRIBUTEVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCHANNELATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBCHANNELATTRIBUTE_ATTRIBUTEVALUE]  DEFAULT ((0)) FOR [ATTRIBUTEVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBCHANNELATTRIBUTE_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBCHANNELATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBCHANNELATTRIBUTE_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBCHANNELATTRIBUTE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBECORESCATEGORY]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBECORESCATEGORY](
[RECID] [bigint] NOT NULL,
[CATEGORYHIERARCHY] [bigint] NOT NULL,
[CHANGESTATUS] [int] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CODE] [nvarchar](20) NOT NULL,
[DEFAULTPROJECTGLOBALCATEGORY] [bigint] NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[ISACTIVE] [int] NOT NULL,
[ISCATEGORYATTRIBUTESINHERITED] [int] NOT NULL,
[ISTANGIBLE] [int] NOT NULL,
[NAME] [nvarchar](254) NOT NULL,
[NESTEDSETLEFT] [bigint] NOT NULL,
[NESTEDSETRIGHT] [bigint] NOT NULL,
[ORIGINID] [bigint] NOT NULL,
[ORIGININSTANCERELATIONTYPE] [bigint] NOT NULL,
[PARENTCATEGORY] [bigint] NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1427327759_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1427327759_516664720] UNIQUE NONCLUSTERED 
(
[NAME] ASC,
[CATEGORYHIERARCHY] ASC,
[CHANNEL] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_CATEGORYHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_CATEGORYHIERARCHY]  DEFAULT ((0)) FOR [CATEGORYHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_CHANGESTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_CHANGESTATUS]  DEFAULT ((0)) FOR [CHANGESTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_CODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_CODE]  DEFAULT ('') FOR [CODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_DEFAULTPROJECTGLOBALCATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_DEFAULTPROJECTGLOBALCATEGORY]  DEFAULT ((0)) FOR [DEFAULTPROJECTGLOBALCATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_ISACTIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_ISACTIVE]  DEFAULT ((0)) FOR [ISACTIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_ISCATEGORYATTRIBUTESINHERITED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_ISCATEGORYATTRIBUTESINHERITED]  DEFAULT ((0)) FOR [ISCATEGORYATTRIBUTESINHERITED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_ISTANGIBLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_ISTANGIBLE]  DEFAULT ((0)) FOR [ISTANGIBLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_NESTEDSETLEFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_NESTEDSETLEFT]  DEFAULT ((0)) FOR [NESTEDSETLEFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_NESTEDSETRIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_NESTEDSETRIGHT]  DEFAULT ((0)) FOR [NESTEDSETRIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_ORIGINID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_ORIGINID]  DEFAULT ((0)) FOR [ORIGINID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_ORIGININSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_ORIGININSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [ORIGININSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_PARENTCATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_PARENTCATEGORY]  DEFAULT ((0)) FOR [PARENTCATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORY_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORY] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORY_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBECORESCATEGORY] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBECORESCATEGORYTRANSLATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION](
[RECID] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](1000) NOT NULL,
[FRIENDLYNAME] [nvarchar](254) NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[ORIGINID] [bigint] NOT NULL,
[SEARCHTEXT] [nvarchar](254) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1633956436_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1633956436_-888948581] UNIQUE CLUSTERED 
(
[CHANNEL] ASC,
[CATEGORY] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_FRIENDLYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_FRIENDLYNAME]  DEFAULT ('') FOR [FRIENDLYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_ORIGINID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_ORIGINID]  DEFAULT ((0)) FOR [ORIGINID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBECORESCATEGORYTRANSLATION_SEARCHTEXT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBECORESCATEGORYTRANSLATION] ADD  CONSTRAINT [DF_RETAILPUBECORESCATEGORYTRANSLATION_SEARCHTEXT]  DEFAULT ('') FOR [SEARCHTEXT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBECORESCATEGORYTRANSLATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP](
[RECID] [bigint] NOT NULL,
[ATTRIBUTEGROUP] [bigint] NOT NULL,
[INTERNALORGANIZATION] [bigint] NOT NULL,
[MODIFIER] [int] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[ORIGINRECVERSION] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1409114826_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1409114826_52244696] UNIQUE CLUSTERED 
(
[INTERNALORGANIZATION] ASC,
[MODIFIER] ASC,
[ATTRIBUTEGROUP] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_ATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP] ADD  CONSTRAINT [DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_ATTRIBUTEGROUP]  DEFAULT ((0)) FOR [ATTRIBUTEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_INTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP] ADD  CONSTRAINT [DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_INTERNALORGANIZATION]  DEFAULT ((0)) FOR [INTERNALORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_MODIFIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP] ADD  CONSTRAINT [DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_MODIFIER]  DEFAULT ((0)) FOR [MODIFIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP] ADD  CONSTRAINT [DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_ORIGINRECVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP] ADD  CONSTRAINT [DF_RETAILPUBINTERNALORGATTRIBUTEGROUP_ORIGINRECVERSION]  DEFAULT ((0)) FOR [ORIGINRECVERSION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBINTERNALORGATTRIBUTEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBINTORGINHERITANCEEXPLODED]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED](
[RECID] [bigint] NOT NULL,
[ANCESTORINTERNALORG] [bigint] NOT NULL,
[DISTANCE] [int] NOT NULL,
[INTERNALORGANIZATION] [bigint] NOT NULL,
[VALIDFROM] [datetime] NOT NULL,
[VALIDFROMTZID] [int] NOT NULL,
[VALIDTO] [datetime] NOT NULL,
[VALIDTOTZID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1617694060_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1617694060_-824416454] UNIQUE NONCLUSTERED 
(
[VALIDFROM] ASC,
[VALIDTO] ASC,
[INTERNALORGANIZATION] ASC,
[ANCESTORINTERNALORG] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_ANCESTORINTERNALORG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_ANCESTORINTERNALORG]  DEFAULT ((0)) FOR [ANCESTORINTERNALORG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_DISTANCE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_DISTANCE]  DEFAULT ((0)) FOR [DISTANCE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_INTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_INTERNALORGANIZATION]  DEFAULT ((0)) FOR [INTERNALORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDFROM]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDFROMTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDFROMTZID]  DEFAULT ((37001)) FOR [VALIDFROMTZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDTO]  DEFAULT ('1900-01-01 00:00:00.000') FOR [VALIDTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDTOTZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] ADD  CONSTRAINT [DF_RETAILPUBINTORGINHERITANCEEXPLODED_VALIDTOTZID]  DEFAULT ((37001)) FOR [VALIDTOTZID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBINTORGINHERITANCEEXPLODED] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[ATTRIBUTERELATIONTYPE] [int] NOT NULL,
[DATATYPE] [int] NOT NULL,
[HOSTCHANNEL] [bigint] NOT NULL,
[KEYNAME] [nvarchar](80) NOT NULL,
[METADATA] [nvarchar](max) NULL,
[METADATAVERSION] [int] NOT NULL,
[ORIGINID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1109106661_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1109106661_139093215] UNIQUE NONCLUSTERED 
(
[HOSTCHANNEL] ASC,
[KEYNAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1109106661_2083805687] UNIQUE NONCLUSTERED 
(
[HOSTCHANNEL] ASC,
[ATTRIBUTE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_ATTRIBUTERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_ATTRIBUTERELATIONTYPE]  DEFAULT ((0)) FOR [ATTRIBUTERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_DATATYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_DATATYPE]  DEFAULT ((0)) FOR [DATATYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_HOSTCHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_HOSTCHANNEL]  DEFAULT ((0)) FOR [HOSTCHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_KEYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_KEYNAME]  DEFAULT ('') FOR [KEYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_METADATAVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_METADATAVERSION]  DEFAULT ((0)) FOR [METADATAVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_ORIGINID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA_ORIGINID]  DEFAULT ((0)) FOR [ORIGINID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBPRODUCTATTRIBUTECHANNELMETADATA] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBPRODUCTATTRIBUTEVALUE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[CATALOG] [bigint] NOT NULL,
[DATETIMEVALUE] [datetime] NOT NULL,
[DATETIMEVALUETZID] [int] NOT NULL,
[FLOATVALUE] [numeric](32, 16) NOT NULL,
[INTERNALORGANIZATION] [bigint] NOT NULL,
[INTVALUE] [int] NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[PRODUCT] [bigint] NOT NULL,
[TEXTVALUE] [nvarchar](1999) NOT NULL,
[UNITOFMEASURE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2054803486_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2054803486_-1059221112] UNIQUE CLUSTERED 
(
[CATALOG] ASC,
[ATTRIBUTE] ASC,
[PRODUCT] ASC,
[INTERNALORGANIZATION] ASC,
[LANGUAGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_CATALOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_CATALOG]  DEFAULT ((0)) FOR [CATALOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_DATETIMEVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_DATETIMEVALUE]  DEFAULT ('1900-01-01 00:00:00.000') FOR [DATETIMEVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_DATETIMEVALUETZID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_DATETIMEVALUETZID]  DEFAULT ((37001)) FOR [DATETIMEVALUETZID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_FLOATVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_FLOATVALUE]  DEFAULT ((0)) FOR [FLOATVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_INTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_INTERNALORGANIZATION]  DEFAULT ((0)) FOR [INTERNALORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_INTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_INTVALUE]  DEFAULT ((0)) FOR [INTVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_PRODUCT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_PRODUCT]  DEFAULT ((0)) FOR [PRODUCT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_TEXTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_TEXTVALUE]  DEFAULT ('') FOR [TEXTVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBPRODUCTATTRIBUTEVALUE_UNITOFMEASURE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] ADD  CONSTRAINT [DF_RETAILPUBPRODUCTATTRIBUTEVALUE_UNITOFMEASURE]  DEFAULT ((0)) FOR [UNITOFMEASURE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBPRODUCTATTRIBUTEVALUE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBRETAILCATALOGPRICEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBRETAILCATALOGPRICEGROUP](
[RECID] [bigint] NOT NULL,
[CATALOG] [bigint] NOT NULL,
[ORIGIN] [bigint] NOT NULL,
[ORIGINRECVERSION] [int] NOT NULL,
[PRICEDISCGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-191513906_RECID] PRIMARY KEY NONCLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-191513906_1077282324] UNIQUE CLUSTERED 
(
[CATALOG] ASC,
[PRICEDISCGROUP] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-191513906_-162312163] UNIQUE NONCLUSTERED 
(
[ORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCATALOGPRICEGROUP_CATALOG]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCATALOGPRICEGROUP] ADD  CONSTRAINT [DF_RETAILPUBRETAILCATALOGPRICEGROUP_CATALOG]  DEFAULT ((0)) FOR [CATALOG]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCATALOGPRICEGROUP_ORIGIN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCATALOGPRICEGROUP] ADD  CONSTRAINT [DF_RETAILPUBRETAILCATALOGPRICEGROUP_ORIGIN]  DEFAULT ((0)) FOR [ORIGIN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCATALOGPRICEGROUP_ORIGINRECVERSION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCATALOGPRICEGROUP] ADD  CONSTRAINT [DF_RETAILPUBRETAILCATALOGPRICEGROUP_ORIGINRECVERSION]  DEFAULT ((0)) FOR [ORIGINRECVERSION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCATALOGPRICEGROUP_PRICEDISCGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCATALOGPRICEGROUP] ADD  CONSTRAINT [DF_RETAILPUBRETAILCATALOGPRICEGROUP_PRICEDISCGROUP]  DEFAULT ((0)) FOR [PRICEDISCGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBRETAILCATALOGPRICEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[ATTRIBUTEVALUE] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[HOSTCHANNEL] [bigint] NOT NULL,
[KEYNAME] [nvarchar](80) NOT NULL,
[ORIGINID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1690411622_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1690411622_-379952457] UNIQUE NONCLUSTERED 
(
[HOSTCHANNEL] ASC,
[CATEGORY] ASC,
[KEYNAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1690411622_-975995985] UNIQUE NONCLUSTERED 
(
[HOSTCHANNEL] ASC,
[CATEGORY] ASC,
[ATTRIBUTE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_ATTRIBUTEVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_ATTRIBUTEVALUE]  DEFAULT ((0)) FOR [ATTRIBUTEVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_HOSTCHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_HOSTCHANNEL]  DEFAULT ((0)) FOR [HOSTCHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_KEYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_KEYNAME]  DEFAULT ('') FOR [KEYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_ORIGINID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE_ORIGINID]  DEFAULT ((0)) FOR [ORIGINID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBRETAILCHANNELCATEGORYATTRIBUTE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBRETAILCHANNELTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBRETAILCHANNELTABLE](
[RECID] [bigint] NOT NULL,
[CATEGORYHIERARCHY] [bigint] NOT NULL,
[CHANNELTYPE] [int] NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[DEFAULTCUSTACCOUNT] [nvarchar](20) NOT NULL,
[DEFAULTCUSTDATAAREAID] [nvarchar](4) NOT NULL,
[INSTANCERELATIONTYPE] [bigint] NOT NULL,
[INTERNALORGANIZATION] [bigint] NOT NULL,
[INVENTLOCATION] [nvarchar](10) NOT NULL,
[INVENTLOCATIONDATAAREAID] [nvarchar](4) NOT NULL,
[OMOPERATINGUNITID] [bigint] NOT NULL,
[ORIGINID] [bigint] NOT NULL,
[ORIGININSTANCERELATIONTYPE] [bigint] NOT NULL,
[PRICEINCLUDESSALESTAX] [int] NOT NULL,
[TRANSACTIONSERVICEPROFILE] [nvarchar](10) NOT NULL,
[RELATIONTYPE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1526824446_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1526824446_-1636812754] UNIQUE NONCLUSTERED 
(
[OMOPERATINGUNITID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1526824446_-1962010936] UNIQUE NONCLUSTERED 
(
[ORIGINID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_CATEGORYHIERARCHY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_CATEGORYHIERARCHY]  DEFAULT ((0)) FOR [CATEGORYHIERARCHY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_CHANNELTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_CHANNELTYPE]  DEFAULT ((0)) FOR [CHANNELTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_DEFAULTCUSTACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_DEFAULTCUSTACCOUNT]  DEFAULT ('') FOR [DEFAULTCUSTACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_DEFAULTCUSTDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_DEFAULTCUSTDATAAREAID]  DEFAULT ('') FOR [DEFAULTCUSTDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_INSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_INSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [INSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_INTERNALORGANIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_INTERNALORGANIZATION]  DEFAULT ((0)) FOR [INTERNALORGANIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_INVENTLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_INVENTLOCATION]  DEFAULT ('') FOR [INVENTLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_INVENTLOCATIONDATAAREAID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_INVENTLOCATIONDATAAREAID]  DEFAULT ('') FOR [INVENTLOCATIONDATAAREAID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_OMOPERATINGUNITID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_OMOPERATINGUNITID]  DEFAULT ((0)) FOR [OMOPERATINGUNITID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_ORIGINID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_ORIGINID]  DEFAULT ((0)) FOR [ORIGINID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_ORIGININSTANCERELATIONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_ORIGININSTANCERELATIONTYPE]  DEFAULT ((0)) FOR [ORIGININSTANCERELATIONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_PRICEINCLUDESSALESTAX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_PRICEINCLUDESSALESTAX]  DEFAULT ((0)) FOR [PRICEINCLUDESSALESTAX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILCHANNELTABLE_TRANSACTIONSERVICEPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILCHANNELTABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILCHANNELTABLE_TRANSACTIONSERVICEPROFILE]  DEFAULT ('') FOR [TRANSACTIONSERVICEPROFILE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBRETAILCHANNELTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES](
[RECID] [bigint] NOT NULL,
[ISDEFAULT] [int] NOT NULL,
[LANGUAGEID] [nvarchar](7) NOT NULL,
[ONLINECHANNEL] [bigint] NOT NULL,
[ORIGINID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2045024010_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_2045024010_985177417] UNIQUE NONCLUSTERED 
(
[LANGUAGEID] ASC,
[ONLINECHANNEL] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_ISDEFAULT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES] ADD  CONSTRAINT [DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_ISDEFAULT]  DEFAULT ((0)) FOR [ISDEFAULT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_LANGUAGEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES] ADD  CONSTRAINT [DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_LANGUAGEID]  DEFAULT ('') FOR [LANGUAGEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_ONLINECHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES] ADD  CONSTRAINT [DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_ONLINECHANNEL]  DEFAULT ((0)) FOR [ONLINECHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_ORIGINID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES] ADD  CONSTRAINT [DF_RETAILPUBRETAILONLINECHANNELLANGUAGES_ORIGINID]  DEFAULT ((0)) FOR [ORIGINID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBRETAILONLINECHANNELLANGUAGES] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBRETAILONLINECHANNELTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBRETAILONLINECHANNELTABLE](
[RECID] [bigint] NOT NULL,
[ONLINECHANNELORIGINID] [bigint] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-709636459_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBRETAILONLINECHANNELTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILPUBRETAILSTORETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILPUBRETAILSTORETABLE](
[RECID] [bigint] NOT NULL,
[CLOSINGMETHOD] [int] NULL,
[CREATELABELSFORZEROPRICE] [int] NULL,
[CULTURENAME] [nvarchar](7) NULL,
[FUNCTIONALITYPROFILE] [nvarchar](10) NULL,
[HIDETRAININGMODE] [int] NULL,
[INVENTLOCATIONIDFORCUSTOMERORDER] [nvarchar](10) NULL,
[INVENTORYLOOKUP] [int] NULL,
[ITEMIDONRECEIPT] [int] NULL,
[LAYOUTID] [nvarchar](10) NULL,
[MAXIMUMPOSTINGDIFFERENCE] [numeric](32, 16) NULL,
[MAXIMUMTEXTLENGTHONRECEIPT] [int] NULL,
[MAXROUNDINGAMOUNT] [numeric](32, 16) NULL,
[MAXROUNDINGTAXAMOUNT] [numeric](32, 16) NULL,
[MAXSHIFTDIFFERENCEAMOUNT] [numeric](32, 16) NULL,
[MAXTRANSACTIONDIFFERENCEAMOUNT] [numeric](32, 16) NULL,
[NUMBEROFTOPORBOTTOMLINES] [int] NULL,
[OFFLINEPROFILE] [bigint] NULL,
[ONESTATEMENTPERDAY] [int] NULL,
[OPENFROM] [int] NULL,
[OPENTO] [int] NULL,
[PHONE] [nvarchar](20) NULL,
[REMOVEADDTENDER] [nvarchar](10) NULL,
[REPLICATIONCOUNTER] [int] NULL,
[ROUNDINGTAXACCOUNT] [nvarchar](20) NULL,
[SERVICECHARGEPCT] [numeric](32, 16) NULL,
[SERVICECHARGEPROMPT] [nvarchar](30) NULL,
[STATEMENTMETHOD] [int] NULL,
[STORENUMBER] [nvarchar](10) NOT NULL,
[STOREORIGINID] [bigint] NULL,
[TAXGROUP] [nvarchar](10) NOT NULL,
[TAXGROUPDATAAREAID] [nvarchar](4) NULL,
[TAXIDENTIFICATIONNUMBER] [nvarchar](25) NULL,
[TAXOVERRIDEGROUP] [bigint] NULL,
[TENDERDECLARATIONCALCULATION] [int] NULL,
[USECUSTOMERBASEDTAX] [int] NULL,
[USEDEFAULTCUSTACCOUNT] [int] NULL,
[USEDESTINATIONBASEDTAX] [int] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_764396596_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILSTORETABLE_STORENUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILSTORETABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILSTORETABLE_STORENUMBER]  DEFAULT ('') FOR [STORENUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILPUBRETAILSTORETABLE_TAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILPUBRETAILSTORETABLE] ADD  CONSTRAINT [DF_RETAILPUBRETAILSTORETABLE_TAXGROUP]  DEFAULT ('') FOR [TAXGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILPUBRETAILSTORETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILRECEIPTMASKS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILRECEIPTMASKS](
[RECID] [bigint] NOT NULL,
[FUNCPROFILEID] [nvarchar](10) NOT NULL,
[ISINDEPENDENT] [int] NOT NULL,
[MASK] [nvarchar](18) NOT NULL,
[RECEIPTTRANSTYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1819627460_-1375636276] PRIMARY KEY CLUSTERED 
(
[FUNCPROFILEID] ASC,
[RECEIPTTRANSTYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTMASKS_FUNCPROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTMASKS] ADD  CONSTRAINT [DF_RETAILRECEIPTMASKS_FUNCPROFILEID]  DEFAULT ('') FOR [FUNCPROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTMASKS_ISINDEPENDENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTMASKS] ADD  CONSTRAINT [DF_RETAILRECEIPTMASKS_ISINDEPENDENT]  DEFAULT ((0)) FOR [ISINDEPENDENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTMASKS_MASK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTMASKS] ADD  CONSTRAINT [DF_RETAILRECEIPTMASKS_MASK]  DEFAULT ('') FOR [MASK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTMASKS_RECEIPTTRANSTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTMASKS] ADD  CONSTRAINT [DF_RETAILRECEIPTMASKS_RECEIPTTRANSTYPE]  DEFAULT ((0)) FOR [RECEIPTTRANSTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILRECEIPTMASKS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILRECEIPTPROFILE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILRECEIPTPROFILE](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[PROFILEID] [nvarchar](10) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-254036412_1714895286] PRIMARY KEY CLUSTERED 
(
[PROFILEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTPROFILE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTPROFILE] ADD  CONSTRAINT [DF_RETAILRECEIPTPROFILE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTPROFILE_PROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTPROFILE] ADD  CONSTRAINT [DF_RETAILRECEIPTPROFILE_PROFILEID]  DEFAULT ('') FOR [PROFILEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILRECEIPTPROFILE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILRECEIPTPROFILELINE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILRECEIPTPROFILELINE](
[RECID] [bigint] NOT NULL,
[FORMLAYOUTID] [nvarchar](10) NOT NULL,
[PROFILEID] [nvarchar](10) NOT NULL,
[RECEIPTTYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1297941798_-1375636276] PRIMARY KEY CLUSTERED 
(
[PROFILEID] ASC,
[RECEIPTTYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTPROFILELINE_FORMLAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTPROFILELINE] ADD  CONSTRAINT [DF_RETAILRECEIPTPROFILELINE_FORMLAYOUTID]  DEFAULT ('') FOR [FORMLAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTPROFILELINE_PROFILEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTPROFILELINE] ADD  CONSTRAINT [DF_RETAILRECEIPTPROFILELINE_PROFILEID]  DEFAULT ('') FOR [PROFILEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILRECEIPTPROFILELINE_RECEIPTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILRECEIPTPROFILELINE] ADD  CONSTRAINT [DF_RETAILRECEIPTPROFILELINE_RECEIPTTYPE]  DEFAULT ((0)) FOR [RECEIPTTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILRECEIPTPROFILELINE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILREPORTLOCALIZEDSTRING]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILREPORTLOCALIZEDSTRING](
[RECID] [bigint] NOT NULL,
[LOCALECODE] [nvarchar](7) NOT NULL,
[STRINGID] [nvarchar](100) NOT NULL,
[STRINGVALUE] [nvarchar](400) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1485736813_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1485736813_-566285944] UNIQUE NONCLUSTERED 
(
[LOCALECODE] ASC,
[STRINGID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILREPORTLOCALIZEDSTRING_LOCALECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILREPORTLOCALIZEDSTRING] ADD  CONSTRAINT [DF_RETAILREPORTLOCALIZEDSTRING_LOCALECODE]  DEFAULT ('') FOR [LOCALECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILREPORTLOCALIZEDSTRING_STRINGID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILREPORTLOCALIZEDSTRING] ADD  CONSTRAINT [DF_RETAILREPORTLOCALIZEDSTRING_STRINGID]  DEFAULT ('') FOR [STRINGID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILREPORTLOCALIZEDSTRING_STRINGVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILREPORTLOCALIZEDSTRING] ADD  CONSTRAINT [DF_RETAILREPORTLOCALIZEDSTRING_STRINGVALUE]  DEFAULT ('') FOR [STRINGVALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILREPORTLOCALIZEDSTRING] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILREPORTPERMISSIONGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILREPORTPERMISSIONGROUP](
[RECID] [bigint] NOT NULL,
[RETAILCHANNELREPORTRECID] [bigint] NOT NULL,
[RETAILPOSPERMISSIONGROUPRECID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1465487581_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1465487581_-738656301] UNIQUE NONCLUSTERED 
(
[RETAILPOSPERMISSIONGROUPRECID] ASC,
[RETAILCHANNELREPORTRECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILREPORTPERMISSIONGROUP_RETAILCHANNELREPORTRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILREPORTPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILREPORTPERMISSIONGROUP_RETAILCHANNELREPORTRECID]  DEFAULT ((0)) FOR [RETAILCHANNELREPORTRECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILREPORTPERMISSIONGROUP_RETAILPOSPERMISSIONGROUPRECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILREPORTPERMISSIONGROUP] ADD  CONSTRAINT [DF_RETAILREPORTPERMISSIONGROUP_RETAILPOSPERMISSIONGROUPRECID]  DEFAULT ((0)) FOR [RETAILPOSPERMISSIONGROUPRECID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILREPORTPERMISSIONGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSALESTAXOVERRIDE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSALESTAXOVERRIDE](
[RECID] [bigint] NOT NULL,
[ADDITIONALDESCRIPTION] [nvarchar](60) NOT NULL,
[CODE] [nvarchar](25) NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[DESTINATIONITEMTAXGROUP] [nvarchar](10) NOT NULL,
[DESTINATIONTAXGROUP] [nvarchar](10) NOT NULL,
[OVERRIDEBY] [int] NOT NULL,
[OVERRIDEFROM] [int] NOT NULL,
[OVERRIDETO] [int] NOT NULL,
[OVERRIDETYPE] [int] NOT NULL,
[SOURCEITEMTAXGROUP] [nvarchar](10) NOT NULL,
[SOURCETAXGROUP] [nvarchar](10) NOT NULL,
[STATUS] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1829403140_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1829403140_776425418] UNIQUE NONCLUSTERED 
(
[CODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_ADDITIONALDESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_ADDITIONALDESCRIPTION]  DEFAULT ('') FOR [ADDITIONALDESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_CODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_CODE]  DEFAULT ('') FOR [CODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_DESTINATIONITEMTAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_DESTINATIONITEMTAXGROUP]  DEFAULT ('') FOR [DESTINATIONITEMTAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_DESTINATIONTAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_DESTINATIONTAXGROUP]  DEFAULT ('') FOR [DESTINATIONTAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_OVERRIDEBY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_OVERRIDEBY]  DEFAULT ((0)) FOR [OVERRIDEBY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_OVERRIDEFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_OVERRIDEFROM]  DEFAULT ((0)) FOR [OVERRIDEFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_OVERRIDETO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_OVERRIDETO]  DEFAULT ((0)) FOR [OVERRIDETO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_OVERRIDETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_OVERRIDETYPE]  DEFAULT ((0)) FOR [OVERRIDETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_SOURCEITEMTAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_SOURCEITEMTAXGROUP]  DEFAULT ('') FOR [SOURCEITEMTAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_SOURCETAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_SOURCETAXGROUP]  DEFAULT ('') FOR [SOURCETAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDE_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDE] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDE_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSALESTAXOVERRIDE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSALESTAXOVERRIDEGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSALESTAXOVERRIDEGROUP](
[RECID] [bigint] NOT NULL,
[CODE] [nvarchar](25) NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1275102027_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1275102027_776425418] UNIQUE NONCLUSTERED 
(
[CODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDEGROUP_CODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDEGROUP] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDEGROUP_CODE]  DEFAULT ('') FOR [CODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDEGROUP_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDEGROUP] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDEGROUP_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSALESTAXOVERRIDEGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSALESTAXOVERRIDEGROUPMEMBER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSALESTAXOVERRIDEGROUPMEMBER](
[RECID] [bigint] NOT NULL,
[RBOSALESTAXOVERRIDECODE] [nvarchar](25) NOT NULL,
[RBOSALESTAXOVERRIDEGROUPCODE] [nvarchar](25) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1138682687_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1138682687_-1481761435] UNIQUE NONCLUSTERED 
(
[RBOSALESTAXOVERRIDEGROUPCODE] ASC,
[RBOSALESTAXOVERRIDECODE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDEGROUPMEMBER_RBOSALESTAXOVERRIDECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDEGROUPMEMBER] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDEGROUPMEMBER_RBOSALESTAXOVERRIDECODE]  DEFAULT ('') FOR [RBOSALESTAXOVERRIDECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSALESTAXOVERRIDEGROUPMEMBER_RBOSALESTAXOVERRIDEGROUPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSALESTAXOVERRIDEGROUPMEMBER] ADD  CONSTRAINT [DF_RETAILSALESTAXOVERRIDEGROUPMEMBER_RBOSALESTAXOVERRIDEGROUPCODE]  DEFAULT ('') FOR [RBOSALESTAXOVERRIDEGROUPCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSALESTAXOVERRIDEGROUPMEMBER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSHAREDBINGPARAMETERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSHAREDBINGPARAMETERS](
[RECID] [bigint] NOT NULL,
[APIKEY] [nvarchar](128) NOT NULL,
[KEY] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1544392866_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1544392866_2053804616] UNIQUE NONCLUSTERED 
(
[KEY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDBINGPARAMETERS_APIKEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDBINGPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDBINGPARAMETERS_APIKEY]  DEFAULT ('') FOR [APIKEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDBINGPARAMETERS_KEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDBINGPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDBINGPARAMETERS_KEY]  DEFAULT ((0)) FOR [KEY]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSHAREDBINGPARAMETERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSHAREDPARAMETERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSHAREDPARAMETERS](
[RECID] [bigint] NOT NULL,
[CATALOGDEFAULTATTRIBUTEGROUP] [bigint] NOT NULL,
[CUSTOMERDEFAULTATTRIBUTEGROUP] [bigint] NOT NULL,
[DEVICETOKENALGORITHM] [nvarchar](25) NOT NULL,
[EARNLOYALTYOFFLINE] [int] NOT NULL,
[EFTPASSWORDENCRYPTION] [nvarchar](25) NOT NULL,
[EXCHANGERATETYPE] [bigint] NOT NULL,
[IMAGESATTRIBUTETYPE] [bigint] NOT NULL,
[KEY] [int] NOT NULL,
[LOCALSTOREID] [nvarchar](10) NOT NULL,
[PRODUCTDEFAULTATTRIBUTEGROUP] [bigint] NOT NULL,
[STAFFPASSWORDHASH] [nvarchar](25) NOT NULL,
[TRANSACTIONSERVICEPROFILE] [nvarchar](10) NOT NULL,
[TSPASSWORDENCRYPTION] [nvarchar](25) NOT NULL,
[VIDEOSATTRIBUTETYPE] [bigint] NOT NULL,
[WORKERDEFAULTATTRIBUTEGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-820738956_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-820738956_2053804616] UNIQUE NONCLUSTERED 
(
[KEY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_CATALOGDEFAULTATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_CATALOGDEFAULTATTRIBUTEGROUP]  DEFAULT ((0)) FOR [CATALOGDEFAULTATTRIBUTEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_CUSTOMERDEFAULTATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_CUSTOMERDEFAULTATTRIBUTEGROUP]  DEFAULT ((0)) FOR [CUSTOMERDEFAULTATTRIBUTEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_DEVICETOKENALGORITHM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_DEVICETOKENALGORITHM]  DEFAULT ('') FOR [DEVICETOKENALGORITHM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_EARNLOYALTYOFFLINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_EARNLOYALTYOFFLINE]  DEFAULT ((0)) FOR [EARNLOYALTYOFFLINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_EFTPASSWORDENCRYPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_EFTPASSWORDENCRYPTION]  DEFAULT ('') FOR [EFTPASSWORDENCRYPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_EXCHANGERATETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_EXCHANGERATETYPE]  DEFAULT ((0)) FOR [EXCHANGERATETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_IMAGESATTRIBUTETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_IMAGESATTRIBUTETYPE]  DEFAULT ((0)) FOR [IMAGESATTRIBUTETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_KEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_KEY]  DEFAULT ((0)) FOR [KEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_LOCALSTOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_LOCALSTOREID]  DEFAULT ('') FOR [LOCALSTOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_PRODUCTDEFAULTATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_PRODUCTDEFAULTATTRIBUTEGROUP]  DEFAULT ((0)) FOR [PRODUCTDEFAULTATTRIBUTEGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_STAFFPASSWORDHASH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_STAFFPASSWORDHASH]  DEFAULT ('') FOR [STAFFPASSWORDHASH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_TRANSACTIONSERVICEPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_TRANSACTIONSERVICEPROFILE]  DEFAULT ('') FOR [TRANSACTIONSERVICEPROFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_TSPASSWORDENCRYPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_TSPASSWORDENCRYPTION]  DEFAULT ('') FOR [TSPASSWORDENCRYPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_VIDEOSATTRIBUTETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_VIDEOSATTRIBUTETYPE]  DEFAULT ((0)) FOR [VIDEOSATTRIBUTETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHAREDPARAMETERS_WORKERDEFAULTATTRIBUTEGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHAREDPARAMETERS] ADD  CONSTRAINT [DF_RETAILSHAREDPARAMETERS_WORKERDEFAULTATTRIBUTEGROUP]  DEFAULT ((0)) FOR [WORKERDEFAULTATTRIBUTEGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSHAREDPARAMETERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSHIPCARRIERACCOUNTCONFIGURATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSHIPCARRIERACCOUNTCONFIGURATION](
[RECID] [bigint] NOT NULL,
[PROPERTYKEY] [nvarchar](60) NOT NULL,
[SHIPCARRIERCOMPANYACCOUNTS] [bigint] NOT NULL,
[VALUE] [nvarchar](60) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_340920594_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_340920594_1680135326] UNIQUE NONCLUSTERED 
(
[PROPERTYKEY] ASC,
[SHIPCARRIERCOMPANYACCOUNTS] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHIPCARRIERACCOUNTCONFIGURATION_PROPERTYKEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHIPCARRIERACCOUNTCONFIGURATION] ADD  CONSTRAINT [DF_RETAILSHIPCARRIERACCOUNTCONFIGURATION_PROPERTYKEY]  DEFAULT ('') FOR [PROPERTYKEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHIPCARRIERACCOUNTCONFIGURATION_SHIPCARRIERCOMPANYACCOUNTS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHIPCARRIERACCOUNTCONFIGURATION] ADD  CONSTRAINT [DF_RETAILSHIPCARRIERACCOUNTCONFIGURATION_SHIPCARRIERCOMPANYACCOUNTS]  DEFAULT ((0)) FOR [SHIPCARRIERCOMPANYACCOUNTS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHIPCARRIERACCOUNTCONFIGURATION_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHIPCARRIERACCOUNTCONFIGURATION] ADD  CONSTRAINT [DF_RETAILSHIPCARRIERACCOUNTCONFIGURATION_VALUE]  DEFAULT ('') FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSHIPCARRIERACCOUNTCONFIGURATION] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSHIPCARRIERINTERFACE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSHIPCARRIERINTERFACE](
[RECID] [bigint] NOT NULL,
[CARRIERADAPTERID] [nvarchar](10) NOT NULL,
[DESCRIPTION] [nvarchar](255) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1914349796_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1914349796_1679934773] UNIQUE NONCLUSTERED 
(
[CARRIERADAPTERID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHIPCARRIERINTERFACE_CARRIERADAPTERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHIPCARRIERINTERFACE] ADD  CONSTRAINT [DF_RETAILSHIPCARRIERINTERFACE_CARRIERADAPTERID]  DEFAULT ('') FOR [CARRIERADAPTERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSHIPCARRIERINTERFACE_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSHIPCARRIERINTERFACE] ADD  CONSTRAINT [DF_RETAILSHIPCARRIERINTERFACE_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSHIPCARRIERINTERFACE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSPECIALCATEGORYMEMBER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSPECIALCATEGORYMEMBER](
[RECID] [bigint] NOT NULL,
[CATEGORY] [bigint] NOT NULL,
[RETAILGROUPMEMBER] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-689542890_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-689542890_191182833] UNIQUE NONCLUSTERED 
(
[RETAILGROUPMEMBER] ASC,
[CATEGORY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSPECIALCATEGORYMEMBER_CATEGORY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSPECIALCATEGORYMEMBER] ADD  CONSTRAINT [DF_RETAILSPECIALCATEGORYMEMBER_CATEGORY]  DEFAULT ((0)) FOR [CATEGORY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSPECIALCATEGORYMEMBER_RETAILGROUPMEMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSPECIALCATEGORYMEMBER] ADD  CONSTRAINT [DF_RETAILSPECIALCATEGORYMEMBER_RETAILGROUPMEMBER]  DEFAULT ((0)) FOR [RETAILGROUPMEMBER]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSPECIALCATEGORYMEMBER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTAFFEXTENDEDLOGON]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTAFFEXTENDEDLOGON](
[RECID] [bigint] NOT NULL,
[EXTRADATA] [varbinary](max) NULL,
[LOGONKEY] [nvarchar](256) NOT NULL,
[LOGONTYPE] [int] NOT NULL,
[STAFF] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-635492541_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-635492541_-1099356344] UNIQUE NONCLUSTERED 
(
[LOGONKEY] ASC,
[LOGONTYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFEXTENDEDLOGON_LOGONKEY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFEXTENDEDLOGON] ADD  CONSTRAINT [DF_RETAILSTAFFEXTENDEDLOGON_LOGONKEY]  DEFAULT ('') FOR [LOGONKEY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFEXTENDEDLOGON_LOGONTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFEXTENDEDLOGON] ADD  CONSTRAINT [DF_RETAILSTAFFEXTENDEDLOGON_LOGONTYPE]  DEFAULT ((0)) FOR [LOGONTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFEXTENDEDLOGON_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFEXTENDEDLOGON] ADD  CONSTRAINT [DF_RETAILSTAFFEXTENDEDLOGON_STAFF]  DEFAULT ((0)) FOR [STAFF]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTAFFEXTENDEDLOGON] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTAFFTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTAFFTABLE](
[RECID] [bigint] NOT NULL,
[BLOCKED] [int] NOT NULL,
[CHANGEPASSWORD] [int] NOT NULL,
[CONTINUEONTSERRORS] [int] NOT NULL,
[CULTURENAME] [nvarchar](7) NOT NULL,
[EMPLOYMENTTYPE] [int] NOT NULL,
[IMAGE] [nvarchar](1999) NOT NULL,
[NAMEONRECEIPT] [nvarchar](15) NOT NULL,
[PASSWORD] [nvarchar](32) NOT NULL,
[PASSWORDDATA] [nvarchar](128) NOT NULL,
[STAFFID] [nvarchar](25) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1254821775_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1254821775_1463232915] UNIQUE NONCLUSTERED 
(
[STAFFID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_BLOCKED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_BLOCKED]  DEFAULT ((0)) FOR [BLOCKED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_CHANGEPASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_CHANGEPASSWORD]  DEFAULT ((0)) FOR [CHANGEPASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_CONTINUEONTSERRORS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_CONTINUEONTSERRORS]  DEFAULT ((0)) FOR [CONTINUEONTSERRORS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_CULTURENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_CULTURENAME]  DEFAULT ('') FOR [CULTURENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_EMPLOYMENTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_EMPLOYMENTTYPE]  DEFAULT ((0)) FOR [EMPLOYMENTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_IMAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_IMAGE]  DEFAULT ('') FOR [IMAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_NAMEONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_NAMEONRECEIPT]  DEFAULT ('') FOR [NAMEONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_PASSWORD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_PASSWORD]  DEFAULT ('') FOR [PASSWORD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_PASSWORDDATA]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_PASSWORDDATA]  DEFAULT ('') FOR [PASSWORDDATA]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_STAFFID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_STAFFID]  DEFAULT ('') FOR [STAFFID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTAFFTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTAFFTABLE] ADD  CONSTRAINT [DF_RETAILSTAFFTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTAFFTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTANDARDATTRIBUTE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTANDARDATTRIBUTE](
[RECID] [bigint] NOT NULL,
[ATTRIBUTE] [bigint] NOT NULL,
[STANDARDATTRIBUTEID] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1439487436_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1439487436_-1724774169] UNIQUE NONCLUSTERED 
(
[STANDARDATTRIBUTEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1439487436_1757139105] UNIQUE NONCLUSTERED 
(
[ATTRIBUTE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTANDARDATTRIBUTE_ATTRIBUTE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTANDARDATTRIBUTE] ADD  CONSTRAINT [DF_RETAILSTANDARDATTRIBUTE_ATTRIBUTE]  DEFAULT ((0)) FOR [ATTRIBUTE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTANDARDATTRIBUTE_STANDARDATTRIBUTEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTANDARDATTRIBUTE] ADD  CONSTRAINT [DF_RETAILSTANDARDATTRIBUTE_STANDARDATTRIBUTEID]  DEFAULT ((0)) FOR [STANDARDATTRIBUTEID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTANDARDATTRIBUTE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTOREADDRESSBOOK]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTOREADDRESSBOOK](
[RECID] [bigint] NOT NULL,
[ADDRESSBOOK] [bigint] NOT NULL,
[ADDRESSBOOKTYPE] [int] NOT NULL,
[STORERECID] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1210059239_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTOREADDRESSBOOK_ADDRESSBOOK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTOREADDRESSBOOK] ADD  CONSTRAINT [DF_RETAILSTOREADDRESSBOOK_ADDRESSBOOK]  DEFAULT ((0)) FOR [ADDRESSBOOK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTOREADDRESSBOOK_ADDRESSBOOKTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTOREADDRESSBOOK] ADD  CONSTRAINT [DF_RETAILSTOREADDRESSBOOK_ADDRESSBOOKTYPE]  DEFAULT ((0)) FOR [ADDRESSBOOKTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTOREADDRESSBOOK_STORERECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTOREADDRESSBOOK] ADD  CONSTRAINT [DF_RETAILSTOREADDRESSBOOK_STORERECID]  DEFAULT ((0)) FOR [STORERECID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTOREADDRESSBOOK] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORECASHDECLARATIONTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORECASHDECLARATIONTABLE](
[RECID] [bigint] NOT NULL,
[AMOUNT] [numeric](32, 16) NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-293880745_1360347954] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[CURRENCY] ASC,
[TYPE] ASC,
[AMOUNT] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORECASHDECLARATIONTABLE_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORECASHDECLARATIONTABLE] ADD  CONSTRAINT [DF_RETAILSTORECASHDECLARATIONTABLE_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORECASHDECLARATIONTABLE_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORECASHDECLARATIONTABLE] ADD  CONSTRAINT [DF_RETAILSTORECASHDECLARATIONTABLE_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORECASHDECLARATIONTABLE_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORECASHDECLARATIONTABLE] ADD  CONSTRAINT [DF_RETAILSTORECASHDECLARATIONTABLE_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORECASHDECLARATIONTABLE_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORECASHDECLARATIONTABLE] ADD  CONSTRAINT [DF_RETAILSTORECASHDECLARATIONTABLE_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORECASHDECLARATIONTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORELOCATORGROUP]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORELOCATORGROUP](
[RECID] [bigint] NOT NULL,
[DESCRIPTION] [nvarchar](60) NOT NULL,
[NAME] [nvarchar](25) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-660604317_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-660604317_-1966747349] UNIQUE NONCLUSTERED 
(
[NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORELOCATORGROUP_DESCRIPTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORELOCATORGROUP] ADD  CONSTRAINT [DF_RETAILSTORELOCATORGROUP_DESCRIPTION]  DEFAULT ('') FOR [DESCRIPTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORELOCATORGROUP_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORELOCATORGROUP] ADD  CONSTRAINT [DF_RETAILSTORELOCATORGROUP_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORELOCATORGROUP] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORELOCATORGROUPMEMBER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORELOCATORGROUPMEMBER](
[RECID] [bigint] NOT NULL,
[LOCATORGROUP] [bigint] NOT NULL,
[STORE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-319812993_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-319812993_-276372453] UNIQUE NONCLUSTERED 
(
[LOCATORGROUP] ASC,
[STORE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORELOCATORGROUPMEMBER_LOCATORGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORELOCATORGROUPMEMBER] ADD  CONSTRAINT [DF_RETAILSTORELOCATORGROUPMEMBER_LOCATORGROUP]  DEFAULT ((0)) FOR [LOCATORGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORELOCATORGROUPMEMBER_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORELOCATORGROUPMEMBER] ADD  CONSTRAINT [DF_RETAILSTORELOCATORGROUPMEMBER_STORE]  DEFAULT ((0)) FOR [STORE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORELOCATORGROUPMEMBER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORELOCATORGROUPOWNER]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORELOCATORGROUPOWNER](
[RECID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[LOCATORGROUP] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2009456858_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-2009456858_-276372453] UNIQUE NONCLUSTERED 
(
[CHANNEL] ASC,
[LOCATORGROUP] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORELOCATORGROUPOWNER_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORELOCATORGROUPOWNER] ADD  CONSTRAINT [DF_RETAILSTORELOCATORGROUPOWNER_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORELOCATORGROUPOWNER_LOCATORGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORELOCATORGROUPOWNER] ADD  CONSTRAINT [DF_RETAILSTORELOCATORGROUPOWNER_LOCATORGROUP]  DEFAULT ((0)) FOR [LOCATORGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORELOCATORGROUPOWNER] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORETABLE](
[RECID] [bigint] NOT NULL,
[CLOSINGMETHOD] [int] NULL,
[CREATELABELSFORZEROPRICE] [int] NULL,
[CULTURENAME] [nvarchar](7) NULL,
[DATABASENAME] [nvarchar](50) NULL,
[FUNCTIONALITYPROFILE] [nvarchar](10) NULL,
[HIDETRAININGMODE] [int] NULL,
[INVENTLOCATIONIDFORCUSTOMERORDER] [nvarchar](10) NULL,
[INVENTORYLOOKUP] [int] NULL,
[ITEMIDONRECEIPT] [int] NULL,
[MAXIMUMPOSTINGDIFFERENCE] [numeric](32, 16) NULL,
[MAXIMUMTEXTLENGTHONRECEIPT] [int] NULL,
[MAXROUNDINGAMOUNT] [numeric](32, 16) NULL,
[MAXROUNDINGTAXAMOUNT] [numeric](32, 16) NULL,
[MAXSHIFTDIFFERENCEAMOUNT] [numeric](32, 16) NULL,
[MAXTRANSACTIONDIFFERENCEAMOUNT] [numeric](32, 16) NULL,
[NUMBEROFTOPORBOTTOMLINES] [int] NULL,
[OFFLINEPROFILE] [bigint] NULL,
[ONESTATEMENTPERDAY] [int] NULL,
[OPENFROM] [int] NULL,
[OPENTO] [int] NULL,
[PASSWORD] [nvarchar](50) NULL,
[PHONE] [nvarchar](20) NULL,
[REMOVEADDTENDER] [nvarchar](10) NULL,
[REPLICATIONCOUNTER] [int] NULL,
[ROUNDINGTAXACCOUNT] [nvarchar](20) NULL,
[SERVICECHARGEPCT] [numeric](32, 16) NULL,
[SERVICECHARGEPROMPT] [nvarchar](30) NULL,
[SQLSERVERNAME] [nvarchar](80) NULL,
[STATEMENTMETHOD] [int] NULL,
[STMTCALCBATCHENDTIME] [int] NULL,
[STMTPOSTASBUSINESSDAY] [int] NULL,
[STORENUMBER] [nvarchar](10) NOT NULL,
[TAXGROUP] [nvarchar](10) NOT NULL,
[TAXGROUPDATAAREAID] [nvarchar](4) NULL,
[TAXIDENTIFICATIONNUMBER] [nvarchar](25) NULL,
[TAXOVERRIDEGROUP] [bigint] NULL,
[TENDERDECLARATIONCALCULATION] [int] NULL,
[USECUSTOMERBASEDTAX] [int] NULL,
[USEDEFAULTCUSTACCOUNT] [int] NULL,
[USEDESTINATIONBASEDTAX] [int] NULL,
[USERNAME] [nvarchar](50) NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-355920874_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-355920874_-94122868] UNIQUE NONCLUSTERED 
(
[STORENUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETABLE_STORENUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETABLE] ADD  CONSTRAINT [DF_RETAILSTORETABLE_STORENUMBER]  DEFAULT ('') FOR [STORENUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETABLE_TAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETABLE] ADD  CONSTRAINT [DF_RETAILSTORETABLE_TAXGROUP]  DEFAULT ('') FOR [TAXGROUP]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORETABLE_IN]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORETABLE_IN](
[RECID] [bigint] NOT NULL,
[RETAILSTORETABLE] [bigint] NOT NULL,
[SALESTAXFORMTYPES] [bigint] NOT NULL,
[SHOWTAXONTAX] [int] NOT NULL,
[TAXDETAILSTYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1889058460_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1889058460_-1306246117] UNIQUE NONCLUSTERED 
(
[RETAILSTORETABLE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETABLE_IN_RETAILSTORETABLE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETABLE_IN] ADD  CONSTRAINT [DF_RETAILSTORETABLE_IN_RETAILSTORETABLE]  DEFAULT ((0)) FOR [RETAILSTORETABLE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETABLE_IN_SALESTAXFORMTYPES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETABLE_IN] ADD  CONSTRAINT [DF_RETAILSTORETABLE_IN_SALESTAXFORMTYPES]  DEFAULT ((0)) FOR [SALESTAXFORMTYPES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETABLE_IN_SHOWTAXONTAX]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETABLE_IN] ADD  CONSTRAINT [DF_RETAILSTORETABLE_IN_SHOWTAXONTAX]  DEFAULT ((0)) FOR [SHOWTAXONTAX]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETABLE_IN_TAXDETAILSTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETABLE_IN] ADD  CONSTRAINT [DF_RETAILSTORETABLE_IN_TAXDETAILSTYPE]  DEFAULT ((0)) FOR [TAXDETAILSTYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORETABLE_IN] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORETENDERTYPECARDTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE](
[RECID] [bigint] NOT NULL,
[ACCOUNTTYPE] [int] NOT NULL,
[ALLOWMANUALINPUT] [int] NOT NULL,
[CARDFEE] [numeric](32, 16) NOT NULL,
[CARDNUMBERSWIPED] [int] NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[CASHBACKLIMIT] [numeric](32, 16) NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CHECKEXPIREDDATE] [int] NOT NULL,
[CHECKMODULUS] [int] NOT NULL,
[COUNTINGREQUIRED] [int] NOT NULL,
[ENTERFLEETINFO] [int] NOT NULL,
[MANUALAUTHORIZATION] [int] NOT NULL,
[MAXNORMALDIFFERENCEAMOUNT] [numeric](32, 16) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[PROCESSLOCALLY] [int] NOT NULL,
[SAMECARDALLOWED] [int] NOT NULL,
[TENDERTYPEID] [nvarchar](10) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1457976754_939570618] PRIMARY KEY CLUSTERED 
(
[CHANNEL] ASC,
[TENDERTYPEID] ASC,
[CARDTYPEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_ACCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_ACCOUNTTYPE]  DEFAULT ((0)) FOR [ACCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_ALLOWMANUALINPUT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_ALLOWMANUALINPUT]  DEFAULT ((0)) FOR [ALLOWMANUALINPUT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CARDFEE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CARDFEE]  DEFAULT ((0)) FOR [CARDFEE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CARDNUMBERSWIPED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CARDNUMBERSWIPED]  DEFAULT ((0)) FOR [CARDNUMBERSWIPED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CASHBACKLIMIT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CASHBACKLIMIT]  DEFAULT ((0)) FOR [CASHBACKLIMIT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CHECKEXPIREDDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CHECKEXPIREDDATE]  DEFAULT ((0)) FOR [CHECKEXPIREDDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_CHECKMODULUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_CHECKMODULUS]  DEFAULT ((0)) FOR [CHECKMODULUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_COUNTINGREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_COUNTINGREQUIRED]  DEFAULT ((0)) FOR [COUNTINGREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_ENTERFLEETINFO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_ENTERFLEETINFO]  DEFAULT ((0)) FOR [ENTERFLEETINFO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_MANUALAUTHORIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_MANUALAUTHORIZATION]  DEFAULT ((0)) FOR [MANUALAUTHORIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_MAXNORMALDIFFERENCEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_MAXNORMALDIFFERENCEAMOUNT]  DEFAULT ((0)) FOR [MAXNORMALDIFFERENCEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_PROCESSLOCALLY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_PROCESSLOCALLY]  DEFAULT ((0)) FOR [PROCESSLOCALLY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_SAMECARDALLOWED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_SAMECARDALLOWED]  DEFAULT ((0)) FOR [SAMECARDALLOWED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_TENDERTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_TENDERTYPEID]  DEFAULT ('') FOR [TENDERTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPECARDTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPECARDTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORETENDERTYPECARDTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILSTORETENDERTYPETABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILSTORETENDERTYPETABLE](
[RECID] [bigint] NOT NULL,
[ABOVEMINIMUMTENDERID] [nvarchar](10) NOT NULL,
[ACCOUNTTYPE] [int] NOT NULL,
[ALLOWFLOAT] [int] NOT NULL,
[ALLOWOVERTENDER] [int] NOT NULL,
[ALLOWRETURNNEGATIVE] [int] NOT NULL,
[ALLOWUNDERTENDER] [int] NOT NULL,
[ASKFORDATE] [int] NOT NULL,
[CHANGELINEONRECEIPT] [nvarchar](20) NOT NULL,
[CHANGETENDERID] [nvarchar](10) NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CHECKPAYEE] [nvarchar](40) NOT NULL,
[COMPRESSPAYMENTENTRIES] [int] NOT NULL,
[COUNTINGREQUIRED] [int] NOT NULL,
[ENDORSECHECK] [int] NOT NULL,
[ENDORSMENTLINE1] [nvarchar](40) NOT NULL,
[ENDORSMENTLINE2] [nvarchar](40) NOT NULL,
[FISCALPRINTERTENDERTYPE_BR] [nvarchar](20) NOT NULL,
[FRONTOFCHECK] [int] NOT NULL,
[FUNCTION] [int] NOT NULL,
[LINENUMINTRANSACTION] [nvarchar](10) NOT NULL,
[MAXCOUNTINGDIFFERENCE] [numeric](32, 16) NOT NULL,
[MAXIMUMAMOUNTALLOWED] [numeric](32, 16) NOT NULL,
[MAXIMUMAMOUNTENTERED] [numeric](32, 16) NOT NULL,
[MAXIMUMOVERTENDERAMOUNT] [numeric](32, 16) NOT NULL,
[MAXRECOUNT] [int] NOT NULL,
[MINIMUMAMOUNTALLOWED] [numeric](32, 16) NOT NULL,
[MINIMUMAMOUNTENTERED] [numeric](32, 16) NOT NULL,
[MINIMUMCHANGEAMOUNT] [numeric](32, 16) NOT NULL,
[MULTIPLYINTENDEROPERATIONS] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[OPENDRAWER] [int] NOT NULL,
[PAYACCOUNTBILL] [int] NOT NULL,
[POSCOUNTENTRIES] [int] NOT NULL,
[POSOPERATION] [int] NOT NULL,
[ROUNDING] [numeric](32, 16) NOT NULL,
[ROUNDINGMETHOD] [int] NOT NULL,
[SEEKAUTHORIZATION] [int] NOT NULL,
[SIGCAPENABLED] [int] NOT NULL,
[SIGCAPMINAMOUNT] [numeric](32, 16) NOT NULL,
[SLIPBACKINPRINTER] [nvarchar](20) NOT NULL,
[SLIPFRONTINPRINTER] [nvarchar](20) NOT NULL,
[TAKENTOBANK] [int] NOT NULL,
[TAKENTOSAFE] [int] NOT NULL,
[TENDERTYPEID] [nvarchar](10) NOT NULL,
[UNDERTENDERAMOUNT] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1697922944_-828827534] PRIMARY KEY CLUSTERED 
(
[CHANNEL] ASC,
[TENDERTYPEID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ABOVEMINIMUMTENDERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ABOVEMINIMUMTENDERID]  DEFAULT ('') FOR [ABOVEMINIMUMTENDERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ACCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ACCOUNTTYPE]  DEFAULT ((0)) FOR [ACCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ALLOWFLOAT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ALLOWFLOAT]  DEFAULT ((0)) FOR [ALLOWFLOAT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ALLOWOVERTENDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ALLOWOVERTENDER]  DEFAULT ((0)) FOR [ALLOWOVERTENDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ALLOWRETURNNEGATIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ALLOWRETURNNEGATIVE]  DEFAULT ((0)) FOR [ALLOWRETURNNEGATIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ALLOWUNDERTENDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ALLOWUNDERTENDER]  DEFAULT ((0)) FOR [ALLOWUNDERTENDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ASKFORDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ASKFORDATE]  DEFAULT ((0)) FOR [ASKFORDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_CHANGELINEONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_CHANGELINEONRECEIPT]  DEFAULT ('') FOR [CHANGELINEONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_CHANGETENDERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_CHANGETENDERID]  DEFAULT ('') FOR [CHANGETENDERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_CHECKPAYEE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_CHECKPAYEE]  DEFAULT ('') FOR [CHECKPAYEE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_COMPRESSPAYMENTENTRIES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_COMPRESSPAYMENTENTRIES]  DEFAULT ((0)) FOR [COMPRESSPAYMENTENTRIES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_COUNTINGREQUIRED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_COUNTINGREQUIRED]  DEFAULT ((0)) FOR [COUNTINGREQUIRED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ENDORSECHECK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ENDORSECHECK]  DEFAULT ((0)) FOR [ENDORSECHECK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ENDORSMENTLINE1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ENDORSMENTLINE1]  DEFAULT ('') FOR [ENDORSMENTLINE1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ENDORSMENTLINE2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ENDORSMENTLINE2]  DEFAULT ('') FOR [ENDORSMENTLINE2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_FISCALPRINTERTENDERTYPE_BR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_FISCALPRINTERTENDERTYPE_BR]  DEFAULT ('') FOR [FISCALPRINTERTENDERTYPE_BR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_FRONTOFCHECK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_FRONTOFCHECK]  DEFAULT ((0)) FOR [FRONTOFCHECK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_FUNCTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_FUNCTION]  DEFAULT ((0)) FOR [FUNCTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_LINENUMINTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_LINENUMINTRANSACTION]  DEFAULT ('') FOR [LINENUMINTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MAXCOUNTINGDIFFERENCE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MAXCOUNTINGDIFFERENCE]  DEFAULT ((0)) FOR [MAXCOUNTINGDIFFERENCE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MAXIMUMAMOUNTALLOWED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MAXIMUMAMOUNTALLOWED]  DEFAULT ((0)) FOR [MAXIMUMAMOUNTALLOWED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MAXIMUMAMOUNTENTERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MAXIMUMAMOUNTENTERED]  DEFAULT ((0)) FOR [MAXIMUMAMOUNTENTERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MAXIMUMOVERTENDERAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MAXIMUMOVERTENDERAMOUNT]  DEFAULT ((0)) FOR [MAXIMUMOVERTENDERAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MAXRECOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MAXRECOUNT]  DEFAULT ((0)) FOR [MAXRECOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MINIMUMAMOUNTALLOWED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MINIMUMAMOUNTALLOWED]  DEFAULT ((0)) FOR [MINIMUMAMOUNTALLOWED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MINIMUMAMOUNTENTERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MINIMUMAMOUNTENTERED]  DEFAULT ((0)) FOR [MINIMUMAMOUNTENTERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MINIMUMCHANGEAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MINIMUMCHANGEAMOUNT]  DEFAULT ((0)) FOR [MINIMUMCHANGEAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_MULTIPLYINTENDEROPERATIONS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_MULTIPLYINTENDEROPERATIONS]  DEFAULT ((0)) FOR [MULTIPLYINTENDEROPERATIONS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_OPENDRAWER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_OPENDRAWER]  DEFAULT ((0)) FOR [OPENDRAWER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_PAYACCOUNTBILL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_PAYACCOUNTBILL]  DEFAULT ((0)) FOR [PAYACCOUNTBILL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_POSCOUNTENTRIES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_POSCOUNTENTRIES]  DEFAULT ((0)) FOR [POSCOUNTENTRIES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_POSOPERATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_POSOPERATION]  DEFAULT ((0)) FOR [POSOPERATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ROUNDING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ROUNDING]  DEFAULT ((0)) FOR [ROUNDING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_ROUNDINGMETHOD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_ROUNDINGMETHOD]  DEFAULT ((0)) FOR [ROUNDINGMETHOD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_SEEKAUTHORIZATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_SEEKAUTHORIZATION]  DEFAULT ((0)) FOR [SEEKAUTHORIZATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_SIGCAPENABLED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_SIGCAPENABLED]  DEFAULT ((0)) FOR [SIGCAPENABLED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_SIGCAPMINAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_SIGCAPMINAMOUNT]  DEFAULT ((0)) FOR [SIGCAPMINAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_SLIPBACKINPRINTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_SLIPBACKINPRINTER]  DEFAULT ('') FOR [SLIPBACKINPRINTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_SLIPFRONTINPRINTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_SLIPFRONTINPRINTER]  DEFAULT ('') FOR [SLIPFRONTINPRINTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_TAKENTOBANK]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_TAKENTOBANK]  DEFAULT ((0)) FOR [TAKENTOBANK]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_TAKENTOSAFE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_TAKENTOSAFE]  DEFAULT ((0)) FOR [TAKENTOSAFE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_TENDERTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_TENDERTYPEID]  DEFAULT ('') FOR [TENDERTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILSTORETENDERTYPETABLE_UNDERTENDERAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILSTORETENDERTYPETABLE] ADD  CONSTRAINT [DF_RETAILSTORETENDERTYPETABLE_UNDERTENDERAMOUNT]  DEFAULT ((0)) FOR [UNDERTENDERAMOUNT]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILSTORETENDERTYPETABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTAXFILTERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTAXFILTERS](
[RECID] [bigint] NOT NULL,
[CITY] [bigint] NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[COUNTYID] [nvarchar](10) NOT NULL,
[DISTRICT] [bigint] NOT NULL,
[STATEID] [nvarchar](10) NOT NULL,
[TAXGROUPHEADING] [nvarchar](10) NOT NULL,
[ZIPCODE] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-491764871_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-491764871_-845285617] UNIQUE NONCLUSTERED 
(
[DISTRICT] ASC,
[ZIPCODE] ASC,
[CITY] ASC,
[COUNTYID] ASC,
[STATEID] ASC,
[COUNTRYREGIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_CITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_CITY]  DEFAULT ((0)) FOR [CITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_COUNTYID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_COUNTYID]  DEFAULT ('') FOR [COUNTYID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_DISTRICT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_DISTRICT]  DEFAULT ((0)) FOR [DISTRICT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_STATEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_STATEID]  DEFAULT ('') FOR [STATEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_TAXGROUPHEADING]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_TAXGROUPHEADING]  DEFAULT ('') FOR [TAXGROUPHEADING]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTAXFILTERS_ZIPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTAXFILTERS] ADD  CONSTRAINT [DF_RETAILTAXFILTERS_ZIPCODE]  DEFAULT ((0)) FOR [ZIPCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTAXFILTERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTENDERTYPECARDNUMBERS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTENDERTYPECARDNUMBERS](
[RECID] [bigint] NOT NULL,
[CARDNUMBERFROM] [nvarchar](30) NOT NULL,
[CARDNUMBERLENGTH] [int] NOT NULL,
[CARDNUMBERTO] [nvarchar](30) NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2117254335_1729673423] PRIMARY KEY CLUSTERED 
(
[CARDTYPEID] ASC,
[CARDNUMBERFROM] ASC,
[CARDNUMBERTO] ASC,
[CARDNUMBERLENGTH] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDNUMBERS_CARDNUMBERFROM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDNUMBERS] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDNUMBERS_CARDNUMBERFROM]  DEFAULT ('') FOR [CARDNUMBERFROM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDNUMBERS_CARDNUMBERLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDNUMBERS] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDNUMBERS_CARDNUMBERLENGTH]  DEFAULT ((0)) FOR [CARDNUMBERLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDNUMBERS_CARDNUMBERTO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDNUMBERS] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDNUMBERS_CARDNUMBERTO]  DEFAULT ('') FOR [CARDNUMBERTO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDNUMBERS_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDNUMBERS] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDNUMBERS_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDNUMBERS_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDNUMBERS] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDNUMBERS_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTENDERTYPECARDNUMBERS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTENDERTYPECARDTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTENDERTYPECARDTABLE](
[RECID] [bigint] NOT NULL,
[CARDISSUER] [nvarchar](60) NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[CARDTYPES] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1446778053_-1743312871] PRIMARY KEY CLUSTERED 
(
[CARDTYPEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDTABLE_CARDISSUER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDTABLE_CARDISSUER]  DEFAULT ('') FOR [CARDISSUER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDTABLE_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDTABLE_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDTABLE_CARDTYPES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDTABLE_CARDTYPES]  DEFAULT ((0)) FOR [CARDTYPES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTENDERTYPECARDTABLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTENDERTYPECARDTABLE] ADD  CONSTRAINT [DF_RETAILTENDERTYPECARDTABLE_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTENDERTYPECARDTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTERMINALCUSTOMFIELD]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTERMINALCUSTOMFIELD](
[RECID] [bigint] NOT NULL,
[CAPTIONTEXTID] [int] NOT NULL,
[NAME] [nvarchar](50) NOT NULL,
[TYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2146898594_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_2146898594_1555050992] UNIQUE NONCLUSTERED 
(
[NAME] ASC,
[TYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALCUSTOMFIELD_CAPTIONTEXTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALCUSTOMFIELD] ADD  CONSTRAINT [DF_RETAILTERMINALCUSTOMFIELD_CAPTIONTEXTID]  DEFAULT ((0)) FOR [CAPTIONTEXTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALCUSTOMFIELD_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALCUSTOMFIELD] ADD  CONSTRAINT [DF_RETAILTERMINALCUSTOMFIELD_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALCUSTOMFIELD_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALCUSTOMFIELD] ADD  CONSTRAINT [DF_RETAILTERMINALCUSTOMFIELD_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTERMINALCUSTOMFIELD] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTERMINALDEVICE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTERMINALDEVICE](
[RECID] [bigint] NOT NULL,
[DEVICE] [bigint] NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1106247877_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1106247877_1900032017] UNIQUE NONCLUSTERED 
(
[TERMINALID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1106247877_-34442163] UNIQUE NONCLUSTERED 
(
[DEVICE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALDEVICE_DEVICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALDEVICE] ADD  CONSTRAINT [DF_RETAILTERMINALDEVICE_DEVICE]  DEFAULT ((0)) FOR [DEVICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALDEVICE_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALDEVICE] ADD  CONSTRAINT [DF_RETAILTERMINALDEVICE_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALDEVICE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALDEVICE] ADD  CONSTRAINT [DF_RETAILTERMINALDEVICE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTERMINALDEVICE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTERMINALTABLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTERMINALTABLE](
[RECID] [bigint] NOT NULL,
[AUTOLOGOFFTIMEOUT] [int] NOT NULL,
[CLOSINGSTATUS] [int] NOT NULL,
[CUSTOMERDISPLAYTEXT1] [nvarchar](40) NOT NULL,
[CUSTOMERDISPLAYTEXT2] [nvarchar](40) NOT NULL,
[EFTSTORERECID] [bigint] NOT NULL,
[EFTTENDERTYPEIDDEFAULT] [nvarchar](10) NOT NULL,
[EFTTERMINALID] [nvarchar](10) NOT NULL,
[EXITAFTEREACHTRANSACTION] [int] NOT NULL,
[HARDWAREPROFILE] [nvarchar](10) NOT NULL,
[IPADDRESS] [nvarchar](255) NOT NULL,
[ITEMIDONRECEIPT] [int] NOT NULL,
[LAYOUTID] [nvarchar](10) NOT NULL,
[LOCATION] [nvarchar](60) NOT NULL,
[MANAGERKEYONRETURN] [int] NOT NULL,
[MAXDISPLAYTEXTLENGTH] [int] NOT NULL,
[MAXRECEIPTTEXTLENGTH] [int] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[NOTACTIVE] [int] NOT NULL,
[NUMBEROFTOPBOTTOMLINES] [int] NOT NULL,
[ONLYTOTALINSUSPENDEDTRANSACTION] [int] NOT NULL,
[OPENDRAWERATLILO] [int] NOT NULL,
[PRINTVATREFUNDCHECKS] [int] NOT NULL,
[RECEIPTBARCODE] [int] NOT NULL,
[RECEIPTPRINTINGDEFAULTOFF] [int] NOT NULL,
[RECEIPTSETUPLOCATION] [int] NOT NULL,
[RETURNINTRANSACTION] [int] NOT NULL,
[SLIPIFRETURN] [int] NOT NULL,
[STANDALONE] [int] NOT NULL,
[STATEMENTMETHOD] [int] NOT NULL,
[STORERECID] [bigint] NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TERMINALSTATEMENT] [int] NOT NULL,
[UPDATESERVICEPORT] [int] NOT NULL,
[VISUALPROFILE] [nvarchar](10) NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1485945225_417776753] PRIMARY KEY CLUSTERED 
(
[TERMINALID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_AUTOLOGOFFTIMEOUT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_AUTOLOGOFFTIMEOUT]  DEFAULT ((0)) FOR [AUTOLOGOFFTIMEOUT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_CLOSINGSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_CLOSINGSTATUS]  DEFAULT ((0)) FOR [CLOSINGSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_CUSTOMERDISPLAYTEXT1]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_CUSTOMERDISPLAYTEXT1]  DEFAULT ('') FOR [CUSTOMERDISPLAYTEXT1]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_CUSTOMERDISPLAYTEXT2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_CUSTOMERDISPLAYTEXT2]  DEFAULT ('') FOR [CUSTOMERDISPLAYTEXT2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_EFTSTORERECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_EFTSTORERECID]  DEFAULT ((0)) FOR [EFTSTORERECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_EFTTENDERTYPEIDDEFAULT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_EFTTENDERTYPEIDDEFAULT]  DEFAULT ('') FOR [EFTTENDERTYPEIDDEFAULT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_EFTTERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_EFTTERMINALID]  DEFAULT ('') FOR [EFTTERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_EXITAFTEREACHTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_EXITAFTEREACHTRANSACTION]  DEFAULT ((0)) FOR [EXITAFTEREACHTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_HARDWAREPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_HARDWAREPROFILE]  DEFAULT ('') FOR [HARDWAREPROFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_IPADDRESS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_IPADDRESS]  DEFAULT ('') FOR [IPADDRESS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_ITEMIDONRECEIPT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_ITEMIDONRECEIPT]  DEFAULT ((0)) FOR [ITEMIDONRECEIPT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_LAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_LAYOUTID]  DEFAULT ('') FOR [LAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_LOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_LOCATION]  DEFAULT ('') FOR [LOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_MANAGERKEYONRETURN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_MANAGERKEYONRETURN]  DEFAULT ((0)) FOR [MANAGERKEYONRETURN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_MAXDISPLAYTEXTLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_MAXDISPLAYTEXTLENGTH]  DEFAULT ((0)) FOR [MAXDISPLAYTEXTLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_MAXRECEIPTTEXTLENGTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_MAXRECEIPTTEXTLENGTH]  DEFAULT ((0)) FOR [MAXRECEIPTTEXTLENGTH]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_NOTACTIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_NOTACTIVE]  DEFAULT ((0)) FOR [NOTACTIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_NUMBEROFTOPBOTTOMLINES]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_NUMBEROFTOPBOTTOMLINES]  DEFAULT ((0)) FOR [NUMBEROFTOPBOTTOMLINES]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_ONLYTOTALINSUSPENDEDTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_ONLYTOTALINSUSPENDEDTRANSACTION]  DEFAULT ((0)) FOR [ONLYTOTALINSUSPENDEDTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_OPENDRAWERATLILO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_OPENDRAWERATLILO]  DEFAULT ((0)) FOR [OPENDRAWERATLILO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_PRINTVATREFUNDCHECKS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_PRINTVATREFUNDCHECKS]  DEFAULT ((0)) FOR [PRINTVATREFUNDCHECKS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_RECEIPTBARCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_RECEIPTBARCODE]  DEFAULT ((0)) FOR [RECEIPTBARCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_RECEIPTPRINTINGDEFAULTOFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_RECEIPTPRINTINGDEFAULTOFF]  DEFAULT ((0)) FOR [RECEIPTPRINTINGDEFAULTOFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_RECEIPTSETUPLOCATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_RECEIPTSETUPLOCATION]  DEFAULT ((0)) FOR [RECEIPTSETUPLOCATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_RETURNINTRANSACTION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_RETURNINTRANSACTION]  DEFAULT ((0)) FOR [RETURNINTRANSACTION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_SLIPIFRETURN]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_SLIPIFRETURN]  DEFAULT ((0)) FOR [SLIPIFRETURN]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_STANDALONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_STANDALONE]  DEFAULT ((0)) FOR [STANDALONE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_STATEMENTMETHOD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_STATEMENTMETHOD]  DEFAULT ((0)) FOR [STATEMENTMETHOD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_STORERECID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_STORERECID]  DEFAULT ((0)) FOR [STORERECID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_TERMINALSTATEMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_TERMINALSTATEMENT]  DEFAULT ((0)) FOR [TERMINALSTATEMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_UPDATESERVICEPORT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_UPDATESERVICEPORT]  DEFAULT ((0)) FOR [UPDATESERVICEPORT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_VISUALPROFILE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_VISUALPROFILE]  DEFAULT ('') FOR [VISUALPROFILE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTERMINALTABLE_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTERMINALTABLE] ADD  CONSTRAINT [DF_RETAILTERMINALTABLE_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTERMINALTABLE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTHEMEACCENT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTHEMEACCENT](
[RECID] [bigint] NOT NULL,
[ACCENTID] [nvarchar](20) NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-428006304_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTHEMEACCENT_ACCENTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTHEMEACCENT] ADD  CONSTRAINT [DF_RETAILTHEMEACCENT_ACCENTID]  DEFAULT ('') FOR [ACCENTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTHEMEACCENT_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTHEMEACCENT] ADD  CONSTRAINT [DF_RETAILTHEMEACCENT_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTHEMEACCENT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTHEMEACCENTCOLOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTHEMEACCENTCOLOR](
[RECID] [bigint] NOT NULL,
[ACCENT] [bigint] NOT NULL,
[COLOR] [int] NOT NULL,
[PALLET] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1375997065_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1375997065_1327556950] UNIQUE NONCLUSTERED 
(
[PALLET] ASC,
[ACCENT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTHEMEACCENTCOLOR_ACCENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTHEMEACCENTCOLOR] ADD  CONSTRAINT [DF_RETAILTHEMEACCENTCOLOR_ACCENT]  DEFAULT ((0)) FOR [ACCENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTHEMEACCENTCOLOR_COLOR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTHEMEACCENTCOLOR] ADD  CONSTRAINT [DF_RETAILTHEMEACCENTCOLOR_COLOR]  DEFAULT ((0)) FOR [COLOR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTHEMEACCENTCOLOR_PALLET]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTHEMEACCENTCOLOR] ADD  CONSTRAINT [DF_RETAILTHEMEACCENTCOLOR_PALLET]  DEFAULT ((0)) FOR [PALLET]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTHEMEACCENTCOLOR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTHEMEPALLET]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTHEMEPALLET](
[RECID] [bigint] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1830151484_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTHEMEPALLET_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTHEMEPALLET] ADD  CONSTRAINT [DF_RETAILTHEMEPALLET_NAME]  DEFAULT ('') FOR [NAME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTHEMEPALLET] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUT]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUT](
[RECID] [bigint] NOT NULL,
[CASHCHANGERLAYOUTXML] [nvarchar](max) NULL,
[CUSTOMERLAYOUTID] [nvarchar](10) NOT NULL,
[CUSTOMERLAYOUTXML] [nvarchar](max) NULL,
[DEVICETYPE] [bigint] NOT NULL,
[HEIGHT] [int] NOT NULL,
[IMG_CASHCHANGERLAYOUTXML] [varbinary](max) NULL,
[LAYOUTID] [nvarchar](10) NOT NULL,
[LAYOUTXML] [nvarchar](max) NULL,
[NAME] [nvarchar](50) NOT NULL,
[RECEIPTID] [nvarchar](10) NOT NULL,
[RECEIPTITEMSLAYOUTXML] [nvarchar](max) NULL,
[RECEIPTPAYMENTLAYOUTXML] [nvarchar](max) NULL,
[TOTALID] [nvarchar](10) NOT NULL,
[TOTALSLAYOUTXML] [nvarchar](max) NULL,
[WIDTH] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1652157140_1814737115] PRIMARY KEY CLUSTERED 
(
[LAYOUTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_CUSTOMERLAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_CUSTOMERLAYOUTID]  DEFAULT ('') FOR [CUSTOMERLAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_DEVICETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_DEVICETYPE]  DEFAULT ((0)) FOR [DEVICETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_HEIGHT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_HEIGHT]  DEFAULT ((0)) FOR [HEIGHT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_LAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_LAYOUTID]  DEFAULT ('') FOR [LAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_RECEIPTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_RECEIPTID]  DEFAULT ('') FOR [RECEIPTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_TOTALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_TOTALID]  DEFAULT ('') FOR [TOTALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUT_WIDTH]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUT] ADD  CONSTRAINT [DF_RETAILTILLLAYOUT_WIDTH]  DEFAULT ((0)) FOR [WIDTH]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUT] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTBUTTONGRIDZONE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTBUTTONGRIDZONE](
[RECID] [bigint] NOT NULL,
[BUTTONGRIDID] [nvarchar](10) NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-611258122_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTBUTTONGRIDZONE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTIMAGEZONE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTIMAGEZONE](
[RECID] [bigint] NOT NULL,
[PICTUREID] [int] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1321184049_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTIMAGEZONE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTREPORTZONE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTREPORTZONE](
[RECID] [bigint] NOT NULL,
[REPORT] [bigint] NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1408251020_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTREPORTZONE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTSTAFF]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTSTAFF](
[RECID] [bigint] NOT NULL,
[LAYOUTID] [nvarchar](10) NOT NULL,
[STAFF] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1600860122_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-1600860122_-519367667] UNIQUE NONCLUSTERED 
(
[LAYOUTID] ASC,
[STAFF] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTSTAFF_LAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTSTAFF] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTSTAFF_LAYOUTID]  DEFAULT ('') FOR [LAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTSTAFF_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTSTAFF] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTSTAFF_STAFF]  DEFAULT ((0)) FOR [STAFF]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTSTAFF] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTSTORE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTSTORE](
[RECID] [bigint] NOT NULL,
[LAYOUTID] [nvarchar](10) NOT NULL,
[STORE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-343952049_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-343952049_1504114108] UNIQUE NONCLUSTERED 
(
[STORE] ASC,
[LAYOUTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTSTORE_LAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTSTORE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTSTORE_LAYOUTID]  DEFAULT ('') FOR [LAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTSTORE_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTSTORE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTSTORE_STORE]  DEFAULT ((0)) FOR [STORE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTSTORE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTZONE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTZONE](
[RECID] [bigint] NOT NULL,
[DEVICETYPE] [bigint] NOT NULL,
[ZONEID] [nvarchar](20) NOT NULL,
[ZONENAME] [nvarchar](60) NOT NULL,
[ZONETYPE] [int] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1703816734_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTZONE_DEVICETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTZONE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTZONE_DEVICETYPE]  DEFAULT ((0)) FOR [DEVICETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTZONE_ZONEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTZONE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTZONE_ZONEID]  DEFAULT ('') FOR [ZONEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTZONE_ZONENAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTZONE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTZONE_ZONENAME]  DEFAULT ('') FOR [ZONENAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTZONE_ZONETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTZONE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTZONE_ZONETYPE]  DEFAULT ((0)) FOR [ZONETYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTZONE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTILLLAYOUTZONEREFERENCE]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTILLLAYOUTZONEREFERENCE](
[RECID] [bigint] NOT NULL,
[LAYOUTID] [nvarchar](10) NOT NULL,
[ZONE] [bigint] NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1413176897_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_1413176897_-199417707] UNIQUE NONCLUSTERED 
(
[ZONE] ASC,
[LAYOUTID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTZONEREFERENCE_LAYOUTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTZONEREFERENCE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTZONEREFERENCE_LAYOUTID]  DEFAULT ('') FOR [LAYOUTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTILLLAYOUTZONEREFERENCE_ZONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTILLLAYOUTZONEREFERENCE] ADD  CONSTRAINT [DF_RETAILTILLLAYOUTZONEREFERENCE_ZONE]  DEFAULT ((0)) FOR [ZONE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTILLLAYOUTZONEREFERENCE] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONADDRESSTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS](
[CHANNEL] [bigint] NOT NULL,
[CITY] [nvarchar](60) NOT NULL,
[COUNTRYREGIONID] [nvarchar](10) NOT NULL,
[COUNTY] [nvarchar](10) NOT NULL,
[DELIVERYNAME] [nvarchar](100) NOT NULL,
[DISTRICTNAME] [nvarchar](60) NOT NULL,
[EMAIL] [nvarchar](80) NOT NULL,
[EMAILCONTENT] [nvarchar](400) NOT NULL,
[PHONE] [nvarchar](20) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SALELINENUM] [numeric](32, 16) NOT NULL,
[SALESNAME] [nvarchar](60) NOT NULL,
[STATE] [nvarchar](10) NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[STREET] [nvarchar](250) NOT NULL,
[STREETNUMBER] [nvarchar](20) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[ZIPCODE] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_2016080543_-1586875080] PRIMARY KEY CLUSTERED 
(
[TRANSACTIONID] ASC,
[TERMINAL] ASC,
[STORE] ASC,
[SALELINENUM] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONADDRESSTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_CITY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_CITY]  DEFAULT ('') FOR [CITY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_COUNTRYREGIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_COUNTRYREGIONID]  DEFAULT ('') FOR [COUNTRYREGIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_COUNTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_COUNTY]  DEFAULT ('') FOR [COUNTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_DELIVERYNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_DELIVERYNAME]  DEFAULT ('') FOR [DELIVERYNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_DISTRICTNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_DISTRICTNAME]  DEFAULT ('') FOR [DISTRICTNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_EMAIL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_EMAIL]  DEFAULT ('') FOR [EMAIL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_EMAILCONTENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_EMAILCONTENT]  DEFAULT ('') FOR [EMAILCONTENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_PHONE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_PHONE]  DEFAULT ('') FOR [PHONE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_SALELINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_SALELINENUM]  DEFAULT ((0)) FOR [SALELINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_SALESNAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_SALESNAME]  DEFAULT ('') FOR [SALESNAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_STATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_STATE]  DEFAULT ('') FOR [STATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_STREET]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_STREET]  DEFAULT ('') FOR [STREET]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_STREETNUMBER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_STREETNUMBER]  DEFAULT ('') FOR [STREETNUMBER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONADDRESSTRANS_ZIPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONADDRESSTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONADDRESSTRANS_ZIPCODE]  DEFAULT ('') FOR [ZIPCODE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONADDRESSTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONAFFILIATIONTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS](
[AFFILIATION] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[LOYALTYTIER] [bigint] NOT NULL,
[RECEIPTID] [nvarchar](18) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STAFFID] [nvarchar](25) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[CREATEDTRANSACTIONID] [bigint] NOT NULL,
[MODIFIEDTRANSACTIONID] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_290532277_-1746289153] PRIMARY KEY CLUSTERED 
(
[AFFILIATION] ASC,
[LOYALTYTIER] ASC,
[CHANNEL] ASC,
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONAFFILIATIONTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_AFFILIATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_AFFILIATION]  DEFAULT ((0)) FOR [AFFILIATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_LOYALTYTIER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_LOYALTYTIER]  DEFAULT ((0)) FOR [LOYALTYTIER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_RECEIPTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_RECEIPTID]  DEFAULT ('') FOR [RECEIPTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_STAFFID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_STAFFID]  DEFAULT ('') FOR [STAFFID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_CREATEDTRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_CREATEDTRANSACTIONID]  DEFAULT ((0)) FOR [CREATEDTRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONAFFILIATIONTRANS_MODIFIEDTRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONAFFILIATIONTRANS_MODIFIEDTRANSACTIONID]  DEFAULT ((0)) FOR [MODIFIEDTRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONAFFILIATIONTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONATTRIBUTETRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS](
[CHANNEL] [bigint] NOT NULL,
[NAME] [nvarchar](60) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TEXTVALUE] [nvarchar](1999) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-1620058971_-2013298691] PRIMARY KEY CLUSTERED 
(
[NAME] ASC,
[TRANSACTIONID] ASC,
[TERMINAL] ASC,
[STORE] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONATTRIBUTETRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONATTRIBUTETRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONATTRIBUTETRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONATTRIBUTETRANS_NAME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONATTRIBUTETRANS_NAME]  DEFAULT ('') FOR [NAME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONATTRIBUTETRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONATTRIBUTETRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONATTRIBUTETRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONATTRIBUTETRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONATTRIBUTETRANS_TEXTVALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONATTRIBUTETRANS_TEXTVALUE]  DEFAULT ('') FOR [TEXTVALUE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONATTRIBUTETRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONATTRIBUTETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONATTRIBUTETRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONATTRIBUTETRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONBANKEDTENDERTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS](
[AMOUNTCUR] [numeric](32, 16) NOT NULL,
[AMOUNTCURPOS] [numeric](32, 16) NOT NULL,
[AMOUNTMST] [numeric](32, 16) NOT NULL,
[AMOUNTMSTPOS] [numeric](32, 16) NOT NULL,
[AMOUNTTENDERED] [numeric](32, 16) NOT NULL,
[AMOUNTTENDEREDPOS] [numeric](32, 16) NOT NULL,
[BANKBAGNO] [nvarchar](30) NOT NULL,
[BUSINESSDATE] [date] NOT NULL,
[CARDORACCOUNT] [nvarchar](30) NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[CHANGELINE] [int] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[COUNTER] [numeric](32, 16) NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[EXCHRATE] [numeric](32, 16) NOT NULL,
[EXCHRATEMST] [numeric](32, 16) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[MANAGERSKEYLIVE] [int] NOT NULL,
[MESSAGENUM] [int] NOT NULL,
[QTY] [numeric](32, 16) NOT NULL,
[REPLICATED] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SHIFT] [nvarchar](10) NOT NULL,
[SHIFTDATE] [date] NOT NULL,
[STAFF] [nvarchar](25) NOT NULL,
[STATEMENTCODE] [nvarchar](25) NOT NULL,
[STATUSTYPE] [int] NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TENDERTYPE] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[TRANSDATE] [date] NOT NULL,
[TRANSTIME] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[CREATEDTRANSACTIONID] [bigint] NOT NULL,
[MODIFIEDTRANSACTIONID] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_85947504_133413727] PRIMARY KEY CLUSTERED 
(
[STORE] ASC,
[TERMINAL] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONBANKEDTENDERTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTCUR]  DEFAULT ((0)) FOR [AMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTCURPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTCURPOS]  DEFAULT ((0)) FOR [AMOUNTCURPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTMST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTMST]  DEFAULT ((0)) FOR [AMOUNTMST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTMSTPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTMSTPOS]  DEFAULT ((0)) FOR [AMOUNTMSTPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTTENDERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTTENDERED]  DEFAULT ((0)) FOR [AMOUNTTENDERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTTENDEREDPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_AMOUNTTENDEREDPOS]  DEFAULT ((0)) FOR [AMOUNTTENDEREDPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_BANKBAGNO]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_BANKBAGNO]  DEFAULT ('') FOR [BANKBAGNO]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_BUSINESSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_BUSINESSDATE]  DEFAULT ('1900-01-01') FOR [BUSINESSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CARDORACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CARDORACCOUNT]  DEFAULT ('') FOR [CARDORACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CHANGELINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CHANGELINE]  DEFAULT ((0)) FOR [CHANGELINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_COUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_COUNTER]  DEFAULT ((0)) FOR [COUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_EXCHRATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_EXCHRATE]  DEFAULT ((0)) FOR [EXCHRATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_EXCHRATEMST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_EXCHRATEMST]  DEFAULT ((0)) FOR [EXCHRATEMST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MANAGERSKEYLIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MANAGERSKEYLIVE]  DEFAULT ((0)) FOR [MANAGERSKEYLIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MESSAGENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MESSAGENUM]  DEFAULT ((0)) FOR [MESSAGENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_REPLICATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_REPLICATED]  DEFAULT ((0)) FOR [REPLICATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_SHIFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_SHIFT]  DEFAULT ('') FOR [SHIFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_SHIFTDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_SHIFTDATE]  DEFAULT ('1900-01-01') FOR [SHIFTDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STAFF]  DEFAULT ('') FOR [STAFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STATEMENTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STATEMENTCODE]  DEFAULT ('') FOR [STATEMENTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STATUSTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STATUSTYPE]  DEFAULT ((0)) FOR [STATUSTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TENDERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TENDERTYPE]  DEFAULT ('') FOR [TENDERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSDATE]  DEFAULT ('1900-01-01') FOR [TRANSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_TRANSTIME]  DEFAULT ((0)) FOR [TRANSTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CREATEDTRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_CREATEDTRANSACTIONID]  DEFAULT ((0)) FOR [CREATEDTRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MODIFIEDTRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONBANKEDTENDERTRANS_MODIFIEDTRANSACTIONID]  DEFAULT ((0)) FOR [MODIFIEDTRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONBANKEDTENDERTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONDISCOUNTTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS](
[AMOUNT] [numeric](32, 16) NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CUSTOMERDISCOUNTTYPE] [int] NOT NULL,
[DEALPRICE] [numeric](32, 16) NOT NULL,
[DISCOUNTAMOUNT] [numeric](32, 16) NOT NULL,
[DISCOUNTCODE] [nvarchar](15) NOT NULL,
[DISCOUNTORIGINTYPE] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[MANUALDISCOUNTTYPE] [int] NOT NULL,
[PERCENTAGE] [numeric](32, 16) NOT NULL,
[PERIODICDISCOUNTOFFERID] [nvarchar](20) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SALELINENUM] [numeric](32, 16) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-363309914_372431339] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[SALELINENUM] ASC,
[CHANNEL] ASC,
[LINENUM] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONDISCOUNTTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_CUSTOMERDISCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_CUSTOMERDISCOUNTTYPE]  DEFAULT ((0)) FOR [CUSTOMERDISCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_DEALPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_DEALPRICE]  DEFAULT ((0)) FOR [DEALPRICE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_DISCOUNTAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_DISCOUNTAMOUNT]  DEFAULT ((0)) FOR [DISCOUNTAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_DISCOUNTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_DISCOUNTCODE]  DEFAULT ('') FOR [DISCOUNTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_DISCOUNTORIGINTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_DISCOUNTORIGINTYPE]  DEFAULT ((0)) FOR [DISCOUNTORIGINTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_MANUALDISCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_MANUALDISCOUNTTYPE]  DEFAULT ((0)) FOR [MANUALDISCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_PERCENTAGE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_PERCENTAGE]  DEFAULT ((0)) FOR [PERCENTAGE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_PERIODICDISCOUNTOFFERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_PERIODICDISCOUNTOFFERID]  DEFAULT ('') FOR [PERIODICDISCOUNTOFFERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_SALELINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_SALELINENUM]  DEFAULT ((0)) FOR [SALELINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONDISCOUNTTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONDISCOUNTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONDISCOUNTTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONDISCOUNTTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS](
[ACCOUNTTYPE] [int] NOT NULL,
[AMOUNT] [numeric](32, 16) NOT NULL,
[BUSINESSDATE] [date] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[COUNTER] [int] NOT NULL,
[INCOMEEXEPENSEACCOUNT] [nvarchar](10) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[RECEIPTID] [nvarchar](18) NOT NULL,
[REPLICATED] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SHIFT] [nvarchar](10) NOT NULL,
[SHIFTDATE] [date] NOT NULL,
[STAFF] [nvarchar](25) NOT NULL,
[STATEMENTCODE] [nvarchar](25) NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[TRANSDATE] [date] NOT NULL,
[TRANSTIME] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1072989706_133413727] PRIMARY KEY CLUSTERED 
(
[STORE] ASC,
[TERMINAL] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONINCOMEEXPENSETRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_ACCOUNTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_ACCOUNTTYPE]  DEFAULT ((0)) FOR [ACCOUNTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_BUSINESSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_BUSINESSDATE]  DEFAULT ('1900-01-01') FOR [BUSINESSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_COUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_COUNTER]  DEFAULT ((0)) FOR [COUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_INCOMEEXEPENSEACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_INCOMEEXEPENSEACCOUNT]  DEFAULT ('') FOR [INCOMEEXEPENSEACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_RECEIPTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_RECEIPTID]  DEFAULT ('') FOR [RECEIPTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_REPLICATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_REPLICATED]  DEFAULT ((0)) FOR [REPLICATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_SHIFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_SHIFT]  DEFAULT ('') FOR [SHIFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_SHIFTDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_SHIFTDATE]  DEFAULT ('1900-01-01') FOR [SHIFTDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_STAFF]  DEFAULT ('') FOR [STAFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_STATEMENTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_STATEMENTCODE]  DEFAULT ('') FOR [STATEMENTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSDATE]  DEFAULT ('1900-01-01') FOR [TRANSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINCOMEEXPENSETRANS_TRANSTIME]  DEFAULT ((0)) FOR [TRANSTIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONINCOMEEXPENSETRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONINFOCODETRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS](
[AMOUNT] [numeric](32, 16) NOT NULL,
[BUSINESSDATE] [date] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[COUNTER] [int] NOT NULL,
[INFOAMOUNT] [numeric](32, 16) NOT NULL,
[INFOCODEID] [nvarchar](10) NOT NULL,
[INFORMATION] [nvarchar](100) NOT NULL,
[INPUTTYPE] [int] NOT NULL,
[ITEMTENDER] [nvarchar](10) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[PARENTLINENUM] [numeric](32, 16) NOT NULL,
[REPLICATED] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SOURCECODE] [nvarchar](20) NOT NULL,
[SOURCECODE2] [nvarchar](20) NOT NULL,
[SOURCECODE3] [nvarchar](20) NOT NULL,
[STAFF] [nvarchar](25) NOT NULL,
[STATEMENTCODE] [nvarchar](25) NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[SUBINFOCODEID] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSDATE] [date] NOT NULL,
[TRANSTIME] [int] NOT NULL,
[TYPE] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_1348077048_-1126114694] PRIMARY KEY CLUSTERED 
(
[STORE] ASC,
[TERMINAL] ASC,
[TYPE] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[INFOCODEID] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONINFOCODETRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_BUSINESSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_BUSINESSDATE]  DEFAULT ('1900-01-01') FOR [BUSINESSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_COUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_COUNTER]  DEFAULT ((0)) FOR [COUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_INFOAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_INFOAMOUNT]  DEFAULT ((0)) FOR [INFOAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_INFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_INFOCODEID]  DEFAULT ('') FOR [INFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_INFORMATION]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_INFORMATION]  DEFAULT ('') FOR [INFORMATION]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_INPUTTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_INPUTTYPE]  DEFAULT ((0)) FOR [INPUTTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_ITEMTENDER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_ITEMTENDER]  DEFAULT ('') FOR [ITEMTENDER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_PARENTLINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_PARENTLINENUM]  DEFAULT ((0)) FOR [PARENTLINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_REPLICATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_REPLICATED]  DEFAULT ((0)) FOR [REPLICATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_SOURCECODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_SOURCECODE]  DEFAULT ('') FOR [SOURCECODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_SOURCECODE2]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_SOURCECODE2]  DEFAULT ('') FOR [SOURCECODE2]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_SOURCECODE3]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_SOURCECODE3]  DEFAULT ('') FOR [SOURCECODE3]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_STAFF]  DEFAULT ('') FOR [STAFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_STATEMENTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_STATEMENTCODE]  DEFAULT ('') FOR [STATEMENTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_SUBINFOCODEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_SUBINFOCODEID]  DEFAULT ('') FOR [SUBINFOCODEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_TRANSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_TRANSDATE]  DEFAULT ('1900-01-01') FOR [TRANSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_TRANSTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_TRANSTIME]  DEFAULT ((0)) FOR [TRANSTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONINFOCODETRANS_TYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONINFOCODETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONINFOCODETRANS_TYPE]  DEFAULT ((0)) FOR [TYPE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONINFOCODETRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS](
[CHANNEL] [bigint] NOT NULL,
[ITEMID] [nvarchar](20) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[QTY] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTER] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[VARIANTID] [nvarchar](10) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-773381400_324085071] PRIMARY KEY CLUSTERED 
(
[LINENUM] ASC,
[CHANNEL] ASC,
[TERMINALID] ASC,
[STOREID] ASC,
[TRANSACTIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_REPLICATIONCOUNTER] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_ITEMID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_ITEMID]  DEFAULT ('') FOR [ITEMID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_VARIANTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONKITSDISASSEMBLYTRANS_VARIANTID]  DEFAULT ('') FOR [VARIANTID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONKITSDISASSEMBLYTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONMARKUPTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS](
[CALCULATEDAMOUNT] [numeric](32, 16) NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[CURRENCYCODE] [nvarchar](3) NOT NULL,
[MARKUPCODE] [nvarchar](10) NOT NULL,
[MARKUPLINENUM] [numeric](32, 16) NOT NULL,
[METHOD] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SALELINENUM] [numeric](32, 16) NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TAXAMOUNT] [numeric](32, 16) NOT NULL,
[TAXAMOUNTEXCLUSIVE] [numeric](32, 16) NOT NULL,
[TAXAMOUNTINCLUSIVE] [numeric](32, 16) NOT NULL,
[TAXGROUP] [nvarchar](10) NOT NULL,
[TAXITEMGROUP] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[VALUE] [numeric](32, 16) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_620503057_-984473184] PRIMARY KEY CLUSTERED 
(
[SALELINENUM] ASC,
[TRANSACTIONID] ASC,
[TERMINALID] ASC,
[STORE] ASC,
[MARKUPLINENUM] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONMARKUPTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_CALCULATEDAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_CALCULATEDAMOUNT]  DEFAULT ((0)) FOR [CALCULATEDAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_CURRENCYCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_CURRENCYCODE]  DEFAULT ('') FOR [CURRENCYCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_MARKUPCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_MARKUPCODE]  DEFAULT ('') FOR [MARKUPCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_MARKUPLINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_MARKUPLINENUM]  DEFAULT ((0)) FOR [MARKUPLINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_METHOD]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_METHOD]  DEFAULT ((0)) FOR [METHOD]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_SALELINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_SALELINENUM]  DEFAULT ((0)) FOR [SALELINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TAXAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TAXAMOUNT]  DEFAULT ((0)) FOR [TAXAMOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TAXAMOUNTEXCLUSIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TAXAMOUNTEXCLUSIVE]  DEFAULT ((0)) FOR [TAXAMOUNTEXCLUSIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TAXAMOUNTINCLUSIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TAXAMOUNTINCLUSIVE]  DEFAULT ((0)) FOR [TAXAMOUNTINCLUSIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TAXGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TAXGROUP]  DEFAULT ('') FOR [TAXGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TAXITEMGROUP]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TAXITEMGROUP]  DEFAULT ('') FOR [TAXITEMGROUP]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONMARKUPTRANS_VALUE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONMARKUPTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONMARKUPTRANS_VALUE]  DEFAULT ((0)) FOR [VALUE]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONMARKUPTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONORDERINVOICETRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS](
[AMOUNTCUR] [numeric](32, 16) NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[INVOICEID] [nvarchar](20) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SALESID] [nvarchar](20) NOT NULL,
[SALESORDERINVOICETYPE] [int] NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_751503198_133413727] PRIMARY KEY CLUSTERED 
(
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONORDERINVOICETRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_AMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_AMOUNTCUR]  DEFAULT ((0)) FOR [AMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_INVOICEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_INVOICEID]  DEFAULT ('') FOR [INVOICEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_SALESID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_SALESID]  DEFAULT ('') FOR [SALESID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_SALESORDERINVOICETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_SALESORDERINVOICETYPE]  DEFAULT ((0)) FOR [SALESORDERINVOICETYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERINVOICETRANS_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERINVOICETRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERINVOICETRANS_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONORDERINVOICETRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONORDERSTATUS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONORDERSTATUS](
[RECID] [bigint] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[ERRORDETAIL] [nvarchar](1024) NOT NULL,
[LASTINVENTTRANS] [bigint] NOT NULL,
[RETRYCOUNT] [int] NOT NULL,
[SALESID] [nvarchar](20) NOT NULL,
[STATUS] [int] NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-832777827_RECID] PRIMARY KEY CLUSTERED 
(
[RECID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [I_-832777827_-915363680] UNIQUE NONCLUSTERED 
(
[TRANSACTIONID] ASC,
[TERMINAL] ASC,
[STORE] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_ERRORDETAIL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_ERRORDETAIL]  DEFAULT ('') FOR [ERRORDETAIL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_LASTINVENTTRANS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_LASTINVENTTRANS]  DEFAULT ((0)) FOR [LASTINVENTTRANS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_RETRYCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_RETRYCOUNT]  DEFAULT ((0)) FOR [RETRYCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_SALESID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_SALESID]  DEFAULT ('') FOR [SALESID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_STATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_STATUS]  DEFAULT ((0)) FOR [STATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONORDERSTATUS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONORDERSTATUS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONORDERSTATUS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONORDERSTATUS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONPAYMENTTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS](
[AMOUNTCUR] [numeric](32, 16) NOT NULL,
[AMOUNTMST] [numeric](32, 16) NOT NULL,
[AMOUNTTENDERED] [numeric](32, 16) NOT NULL,
[AUTHENTICATIONCODE] [nvarchar](20) NOT NULL,
[BUSINESSDATE] [date] NOT NULL,
[CARDORACCOUNT] [nvarchar](30) NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[CASHDOCID_RU] [nvarchar](20) NOT NULL,
[CHANGELINE] [int] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[COUNTER] [int] NOT NULL,
[CREDITVOUCHERID] [nvarchar](30) NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[EXCHRATE] [numeric](32, 16) NOT NULL,
[EXCHRATEMST] [numeric](32, 16) NOT NULL,
[GIFTCARDID] [nvarchar](30) NOT NULL,
[ISPREPAYMENT] [int] NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[LOYALTYCARDID] [nvarchar](30) NOT NULL,
[MANAGERKEYLIVE] [int] NOT NULL,
[MESSAGENUM] [int] NOT NULL,
[PAYMENTAUTHORIZATION] [nvarchar](max) NULL,
[QTY] [numeric](32, 16) NOT NULL,
[RECEIPTID] [nvarchar](18) NOT NULL,
[REPLICATED] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SHIFT] [nvarchar](10) NOT NULL,
[SHIFTDATE] [date] NOT NULL,
[SIGCAPDATA] [nvarchar](max) NULL,
[STAFF] [nvarchar](25) NOT NULL,
[STATEMENTCODE] [nvarchar](25) NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TENDERTYPE] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[TRANSDATE] [date] NOT NULL,
[TRANSTIME] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_371784663_133413727] PRIMARY KEY CLUSTERED 
(
[STORE] ASC,
[TERMINAL] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONPAYMENTTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_AMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_AMOUNTCUR]  DEFAULT ((0)) FOR [AMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_AMOUNTMST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_AMOUNTMST]  DEFAULT ((0)) FOR [AMOUNTMST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_AMOUNTTENDERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_AMOUNTTENDERED]  DEFAULT ((0)) FOR [AMOUNTTENDERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_AUTHENTICATIONCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_AUTHENTICATIONCODE]  DEFAULT ('') FOR [AUTHENTICATIONCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BUSINESSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BUSINESSDATE]  DEFAULT ('1900-01-01') FOR [BUSINESSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CARDORACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CARDORACCOUNT]  DEFAULT ('') FOR [CARDORACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CASHDOCID_RU]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CASHDOCID_RU]  DEFAULT ('') FOR [CASHDOCID_RU]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CHANGELINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CHANGELINE]  DEFAULT ((0)) FOR [CHANGELINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_COUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_COUNTER]  DEFAULT ((0)) FOR [COUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CREDITVOUCHERID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CREDITVOUCHERID]  DEFAULT ('') FOR [CREDITVOUCHERID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_EXCHRATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_EXCHRATE]  DEFAULT ((0)) FOR [EXCHRATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_EXCHRATEMST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_EXCHRATEMST]  DEFAULT ((0)) FOR [EXCHRATEMST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_GIFTCARDID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_GIFTCARDID]  DEFAULT ('') FOR [GIFTCARDID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_ISPREPAYMENT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_ISPREPAYMENT]  DEFAULT ((0)) FOR [ISPREPAYMENT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_LOYALTYCARDID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_LOYALTYCARDID]  DEFAULT ('') FOR [LOYALTYCARDID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_MANAGERKEYLIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_MANAGERKEYLIVE]  DEFAULT ((0)) FOR [MANAGERKEYLIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_MESSAGENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_MESSAGENUM]  DEFAULT ((0)) FOR [MESSAGENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_RECEIPTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_RECEIPTID]  DEFAULT ('') FOR [RECEIPTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_REPLICATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_REPLICATED]  DEFAULT ((0)) FOR [REPLICATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_SHIFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_SHIFT]  DEFAULT ('') FOR [SHIFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_SHIFTDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_SHIFTDATE]  DEFAULT ('1900-01-01') FOR [SHIFTDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_STAFF]  DEFAULT ('') FOR [STAFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_STATEMENTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_STATEMENTCODE]  DEFAULT ('') FOR [STATEMENTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_TENDERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_TENDERTYPE]  DEFAULT ('') FOR [TENDERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSDATE]  DEFAULT ('1900-01-01') FOR [TRANSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_TRANSTIME]  DEFAULT ((0)) FOR [TRANSTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_CREATEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_CREATEDDATETIME]  DEFAULT (getutcdate()) FOR [CREATEDDATETIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_MODIFIEDDATETIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_MODIFIEDDATETIME]  DEFAULT (getutcdate()) FOR [MODIFIEDDATETIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONPAYMENTTRANS] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONPAYMENTTRANS_BR]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR](
[AMOUNTCUR] [numeric](32, 16) NOT NULL,
[AMOUNTTENDERED] [numeric](32, 16) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[STOREID] [nvarchar](10) NOT NULL,
[TENDERTYPE] [nvarchar](10) NOT NULL,
[TERMINALID] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[TRANSDATE] [date] NOT NULL,
[TRANSTIME] [int] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_818850008_-1103390687] PRIMARY KEY CLUSTERED 
(
[LINENUM] ASC,
[STOREID] ASC,
[TERMINALID] ASC,
[TRANSACTIONID] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONPAYMENTTRANS_BR_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_AMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_AMOUNTCUR]  DEFAULT ((0)) FOR [AMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_AMOUNTTENDERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_AMOUNTTENDERED]  DEFAULT ((0)) FOR [AMOUNTTENDERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_STOREID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_STOREID]  DEFAULT ('') FOR [STOREID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TENDERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TENDERTYPE]  DEFAULT ('') FOR [TENDERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TERMINALID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TERMINALID]  DEFAULT ('') FOR [TERMINALID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSDATE]  DEFAULT ('1900-01-01') FOR [TRANSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] ADD  CONSTRAINT [DF_RETAILTRANSACTIONPAYMENTTRANS_BR_TRANSTIME]  DEFAULT ((0)) FOR [TRANSTIME]
END

GO
GRANT DELETE, INSERT, SELECT, UPDATE ON [ax].[RETAILTRANSACTIONPAYMENTTRANS_BR] TO [DataSyncUsersRole]
GO
-------------------------------------------------------------------------------
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ax].[RETAILTRANSACTIONSAFETENDERTRANS]') AND type in (N'U'))
BEGIN
CREATE TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS](
[AMOUNTCUR] [numeric](32, 16) NOT NULL,
[AMOUNTCURPOS] [numeric](32, 16) NOT NULL,
[AMOUNTMST] [numeric](32, 16) NOT NULL,
[AMOUNTMSTPOS] [numeric](32, 16) NOT NULL,
[AMOUNTTENDERED] [numeric](32, 16) NOT NULL,
[AMOUNTTENDEREDPOS] [numeric](32, 16) NOT NULL,
[BUSINESSDATE] [date] NOT NULL,
[CARDORACCOUNT] [nvarchar](30) NOT NULL,
[CARDTYPEID] [nvarchar](10) NOT NULL,
[CHANGELINE] [int] NOT NULL,
[CHANNEL] [bigint] NOT NULL,
[COUNTER] [numeric](32, 16) NOT NULL,
[CURRENCY] [nvarchar](3) NOT NULL,
[EXCHRATE] [numeric](32, 16) NOT NULL,
[EXCHRATEMST] [numeric](32, 16) NOT NULL,
[LINENUM] [numeric](32, 16) NOT NULL,
[MANAGERSKEYLIVE] [int] NOT NULL,
[MESSAGENUM] [int] NOT NULL,
[QTY] [numeric](32, 16) NOT NULL,
[REPLICATED] [int] NOT NULL,
[REPLICATIONCOUNTERFROMORIGIN] [int] IDENTITY(1,1) NOT NULL,
[SHIFT] [nvarchar](10) NOT NULL,
[SHIFTDATE] [date] NOT NULL,
[STAFF] [nvarchar](25) NOT NULL,
[STATEMENTCODE] [nvarchar](25) NOT NULL,
[STATEMENTID] [nvarchar](20) NOT NULL,
[STATUSTYPE] [int] NOT NULL,
[STORE] [nvarchar](10) NOT NULL,
[TENDERTYPE] [nvarchar](10) NOT NULL,
[TERMINAL] [nvarchar](10) NOT NULL,
[TRANSACTIONID] [nvarchar](44) NOT NULL,
[TRANSACTIONSTATUS] [int] NOT NULL,
[TRANSDATE] [date] NOT NULL,
[TRANSTIME] [int] NOT NULL,
[CREATEDDATETIME] [datetime] NOT NULL,
[MODIFIEDDATETIME] [datetime] NOT NULL,
[CREATEDTRANSACTIONID] [bigint] NOT NULL,
[MODIFIEDTRANSACTIONID] [bigint] NOT NULL,
[DATAAREAID] [nvarchar](4) NOT NULL,
[ROWVERSION] [timestamp] NOT NULL,
 CONSTRAINT [I_-2051633402_133413727] PRIMARY KEY CLUSTERED 
(
[STORE] ASC,
[TERMINAL] ASC,
[TRANSACTIONID] ASC,
[LINENUM] ASC,
[STATEMENTID] ASC,
[CHANNEL] ASC,
[DATAAREAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UI_RETAILTRANSACTIONSAFETENDERTRANS_REPLICATIONCOUNTERFROMORIGIN] UNIQUE NONCLUSTERED 
(
[REPLICATIONCOUNTERFROMORIGIN] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTCUR]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTCUR]  DEFAULT ((0)) FOR [AMOUNTCUR]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTCURPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTCURPOS]  DEFAULT ((0)) FOR [AMOUNTCURPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTMST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTMST]  DEFAULT ((0)) FOR [AMOUNTMST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTMSTPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTMSTPOS]  DEFAULT ((0)) FOR [AMOUNTMSTPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTTENDERED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTTENDERED]  DEFAULT ((0)) FOR [AMOUNTTENDERED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTTENDEREDPOS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_AMOUNTTENDEREDPOS]  DEFAULT ((0)) FOR [AMOUNTTENDEREDPOS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_BUSINESSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_BUSINESSDATE]  DEFAULT ('1900-01-01') FOR [BUSINESSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_CARDORACCOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_CARDORACCOUNT]  DEFAULT ('') FOR [CARDORACCOUNT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_CARDTYPEID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_CARDTYPEID]  DEFAULT ('') FOR [CARDTYPEID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_CHANGELINE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_CHANGELINE]  DEFAULT ((0)) FOR [CHANGELINE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_CHANNEL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_CHANNEL]  DEFAULT ((0)) FOR [CHANNEL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_COUNTER]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_COUNTER]  DEFAULT ((0)) FOR [COUNTER]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_CURRENCY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_CURRENCY]  DEFAULT ('') FOR [CURRENCY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_EXCHRATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_EXCHRATE]  DEFAULT ((0)) FOR [EXCHRATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_EXCHRATEMST]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_EXCHRATEMST]  DEFAULT ((0)) FOR [EXCHRATEMST]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_LINENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_LINENUM]  DEFAULT ((0)) FOR [LINENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_MANAGERSKEYLIVE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_MANAGERSKEYLIVE]  DEFAULT ((0)) FOR [MANAGERSKEYLIVE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_MESSAGENUM]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_MESSAGENUM]  DEFAULT ((0)) FOR [MESSAGENUM]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_QTY]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_QTY]  DEFAULT ((0)) FOR [QTY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_REPLICATED]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_REPLICATED]  DEFAULT ((0)) FOR [REPLICATED]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_SHIFT]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_SHIFT]  DEFAULT ('') FOR [SHIFT]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_SHIFTDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_SHIFTDATE]  DEFAULT ('1900-01-01') FOR [SHIFTDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_STAFF]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_STAFF]  DEFAULT ('') FOR [STAFF]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_STATEMENTCODE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_STATEMENTCODE]  DEFAULT ('') FOR [STATEMENTCODE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_STATEMENTID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_STATEMENTID]  DEFAULT ('') FOR [STATEMENTID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_STATUSTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_STATUSTYPE]  DEFAULT ((0)) FOR [STATUSTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_STORE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_STORE]  DEFAULT ('') FOR [STORE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_TENDERTYPE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_TENDERTYPE]  DEFAULT ('') FOR [TENDERTYPE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_TERMINAL]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_TERMINAL]  DEFAULT ('') FOR [TERMINAL]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSACTIONID]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSACTIONID]  DEFAULT ('') FOR [TRANSACTIONID]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSACTIONSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSACTIONSTATUS]  DEFAULT ((0)) FOR [TRANSACTIONSTATUS]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSDATE]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSDATE]  DEFAULT ('1900-01-01') FOR [TRANSDATE]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ax].[DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSTIME]') AND type = 'D')
BEGIN
ALTER TABLE [ax].[RETAILTRANSACTIONSAFETENDERTRANS] ADD  CONSTRAINT [DF_RETAILTRANSACTIONSAFETENDERTRANS_TRANSTIME]  DEFAULT ((0)) FOR [TRANSTIME]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = O