<?xml version="1.0"?>

<data>
	<tables-sql><![CDATA[create table OA2Auths_OA2ScopeGrants (
	companyId LONG not null,
	oAuth2AuthorizationId LONG not null,
	oAuth2ScopeGrantId LONG not null,
	primary key (oAuth2AuthorizationId, oAuth2ScopeGrantId)
);

create table OAuth2Application (
	uuid_ VARCHAR(75) null,
	externalReferenceCode VARCHAR(75) null,
	oAuth2ApplicationId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	oA2AScopeAliasesId LONG,
	allowedGrantTypes VARCHAR(128) null,
	clientAuthenticationMethod VARCHAR(75) null,
	clientCredentialUserId LONG,
	clientCredentialUserName VARCHAR(75) null,
	clientId VARCHAR(75) null,
	clientProfile INTEGER,
	clientSecret VARCHAR(75) null,
	description STRING null,
	features STRING null,
	homePageURL STRING null,
	iconFileEntryId LONG,
	jwks VARCHAR(3999) null,
	name VARCHAR(255) null,
	privacyPolicyURL STRING null,
	redirectURIs STRING null,
	rememberDevice BOOLEAN,
	trustedApplication BOOLEAN
);

create table OAuth2ApplicationScopeAliases (
	oA2AScopeAliasesId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	oAuth2ApplicationId LONG
);

create table OAuth2Authorization (
	oAuth2AuthorizationId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	oAuth2ApplicationId LONG,
	oA2AScopeAliasesId LONG,
	accessTokenContent TEXT null,
	accessTokenContentHash LONG,
	accessTokenCreateDate DATE null,
	accessTokenExpirationDate DATE null,
	remoteHostInfo VARCHAR(255) null,
	remoteIPInfo VARCHAR(75) null,
	refreshTokenContent TEXT null,
	refreshTokenContentHash LONG,
	refreshTokenCreateDate DATE null,
	refreshTokenExpirationDate DATE null,
	rememberDeviceContent VARCHAR(75) null
);

create table OAuth2ScopeGrant (
	oAuth2ScopeGrantId LONG not null primary key,
	companyId LONG,
	oA2AScopeAliasesId LONG,
	applicationName VARCHAR(255) null,
	bundleSymbolicName VARCHAR(255) null,
	scope VARCHAR(240) null,
	scopeAliases TEXT null
);]]></tables-sql>
	<sequences-sql><![CDATA[]]></sequences-sql>
	<indexes-sql><![CDATA[create index IX_87DAF9C3 on OA2Auths_OA2ScopeGrants (companyId);
create index IX_2F541817 on OA2Auths_OA2ScopeGrants (oAuth2ScopeGrantId);

create index IX_523E5C67 on OAuth2Application (companyId, clientId[$COLUMN_LENGTH:75$]);
create index IX_949C9C01 on OAuth2Application (companyId, clientProfile);
create unique index IX_67BC29B0 on OAuth2Application (companyId, externalReferenceCode[$COLUMN_LENGTH:75$]);
create index IX_361558F9 on OAuth2Application (uuid_[$COLUMN_LENGTH:75$]);

create index IX_282ECE83 on OAuth2ApplicationScopeAliases (companyId);
create index IX_2F9EBCBB on OAuth2ApplicationScopeAliases (oAuth2ApplicationId);

create index IX_FB9F7B8A on OAuth2Authorization (companyId, accessTokenContentHash);
create index IX_673EE35 on OAuth2Authorization (companyId, refreshTokenContentHash);
create index IX_70DD169C on OAuth2Authorization (oAuth2ApplicationId);
create index IX_EFE93C04 on OAuth2Authorization (userId, oAuth2ApplicationId, rememberDeviceContent[$COLUMN_LENGTH:75$]);

create index IX_8E6F6B4B on OAuth2ScopeGrant (oA2AScopeAliasesId, companyId, applicationName[$COLUMN_LENGTH:255$], bundleSymbolicName[$COLUMN_LENGTH:255$], scope[$COLUMN_LENGTH:240$]);]]></indexes-sql>
</data>