FederationStateStoreTables.sql 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. USE [FederationStateStore]
  19. GO
  20. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  21. WHERE name = 'applicationsHomeSubCluster'
  22. AND schema_id = SCHEMA_ID('dbo'))
  23. BEGIN
  24. PRINT 'Table applicationsHomeSubCluster does not exist, create it...'
  25. SET ANSI_NULLS ON
  26. SET QUOTED_IDENTIFIER ON
  27. SET ANSI_PADDING ON
  28. CREATE TABLE [dbo].[applicationsHomeSubCluster](
  29. applicationId VARCHAR(64) COLLATE Latin1_General_100_BIN2 NOT NULL,
  30. homeSubCluster VARCHAR(256) NOT NULL,
  31. createTime DATETIME2 NOT NULL CONSTRAINT ts_createAppTime DEFAULT GETUTCDATE(),
  32. CONSTRAINT [pk_applicationId] PRIMARY KEY
  33. (
  34. [applicationId]
  35. )
  36. )
  37. SET ANSI_PADDING OFF
  38. PRINT 'Table applicationsHomeSubCluster created.'
  39. END
  40. ELSE
  41. PRINT 'Table applicationsHomeSubCluster exists, no operation required...'
  42. GO
  43. GO
  44. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  45. WHERE name = 'membership'
  46. AND schema_id = SCHEMA_ID('dbo'))
  47. BEGIN
  48. PRINT 'Table membership does not exist, create it...'
  49. SET ANSI_NULLS ON
  50. SET QUOTED_IDENTIFIER ON
  51. SET ANSI_PADDING ON
  52. CREATE TABLE [dbo].[membership](
  53. [subClusterId] VARCHAR(256) COLLATE Latin1_General_100_BIN2 NOT NULL,
  54. [amRMServiceAddress] VARCHAR(256) NOT NULL,
  55. [clientRMServiceAddress] VARCHAR(256) NOT NULL,
  56. [rmAdminServiceAddress] VARCHAR(256) NOT NULL,
  57. [rmWebServiceAddress] VARCHAR(256) NOT NULL,
  58. [lastHeartBeat] DATETIME2 NOT NULL,
  59. [state] VARCHAR(32) NOT NULL,
  60. [lastStartTime] BIGINT NOT NULL,
  61. [capability] VARCHAR(6000) NOT NULL,
  62. CONSTRAINT [pk_subClusterId] PRIMARY KEY
  63. (
  64. [subClusterId]
  65. ),
  66. CONSTRAINT [uc_lastStartTime] UNIQUE
  67. (
  68. [lastStartTime]
  69. )
  70. )
  71. SET ANSI_PADDING OFF
  72. PRINT 'Table membership created.'
  73. END
  74. ELSE
  75. PRINT 'Table membership exists, no operation required...'
  76. GO
  77. GO
  78. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  79. WHERE name = 'policies'
  80. AND schema_id = SCHEMA_ID('dbo'))
  81. BEGIN
  82. PRINT 'Table policies does not exist, create it...'
  83. SET ANSI_NULLS ON
  84. SET QUOTED_IDENTIFIER ON
  85. SET ANSI_PADDING ON
  86. CREATE TABLE [dbo].[policies](
  87. queue VARCHAR(256) COLLATE Latin1_General_100_BIN2 NOT NULL,
  88. policyType VARCHAR(256) NOT NULL,
  89. params VARBINARY(6000) NOT NULL,
  90. CONSTRAINT [pk_queue] PRIMARY KEY
  91. (
  92. [queue]
  93. )
  94. )
  95. SET ANSI_PADDING OFF
  96. PRINT 'Table policies created.'
  97. END
  98. ELSE
  99. PRINT 'Table policies exists, no operation required...'
  100. GO
  101. GO
  102. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  103. WHERE name = 'reservationsHomeSubCluster'
  104. AND schema_id = SCHEMA_ID('dbo'))
  105. BEGIN
  106. PRINT 'Table reservationsHomeSubCluster does not exist, create it...'
  107. SET ANSI_NULLS ON
  108. SET QUOTED_IDENTIFIER ON
  109. SET ANSI_PADDING ON
  110. CREATE TABLE [dbo].[reservationsHomeSubCluster](
  111. reservationId VARCHAR(128) COLLATE Latin1_General_100_BIN2 NOT NULL,
  112. homeSubCluster VARCHAR(256) NOT NULL,
  113. createTime DATETIME2 NOT NULL CONSTRAINT ts_createResTime DEFAULT GETUTCDATE(),
  114. CONSTRAINT [pk_reservationId] PRIMARY KEY
  115. (
  116. [reservationId]
  117. )
  118. )
  119. SET ANSI_PADDING OFF
  120. PRINT 'Table reservationsHomeSubCluster created.'
  121. END
  122. ELSE
  123. PRINT 'Table reservationsHomeSubCluster exists, no operation required...'
  124. GO
  125. GO
  126. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  127. WHERE name = 'masterKeys'
  128. AND schema_id = SCHEMA_ID('dbo'))
  129. BEGIN
  130. PRINT 'Table masterKeys does not exist, create it...'
  131. SET ANSI_NULLS ON
  132. SET QUOTED_IDENTIFIER ON
  133. SET ANSI_PADDING ON
  134. CREATE TABLE [dbo].[masterKeys](
  135. keyId BIGINT NOT NULL,
  136. masterKey VARCHAR(1024) NOT NULL,
  137. CONSTRAINT [pk_keyId] PRIMARY KEY
  138. (
  139. [keyId]
  140. )
  141. )
  142. SET ANSI_PADDING OFF
  143. PRINT 'Table masterKeys created.'
  144. END
  145. ELSE
  146. PRINT 'Table masterKeys exists, no operation required...'
  147. GO
  148. GO
  149. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  150. WHERE name = 'delegationTokens'
  151. AND schema_id = SCHEMA_ID('dbo'))
  152. BEGIN
  153. PRINT 'Table delegationTokens does not exist, create it...'
  154. SET ANSI_NULLS ON
  155. SET QUOTED_IDENTIFIER ON
  156. SET ANSI_PADDING ON
  157. CREATE TABLE [dbo].[delegationTokens](
  158. sequenceNum BIGINT NOT NULL,
  159. tokenIdent VARCHAR(1024) NOT NULL,
  160. token VARCHAR(1024) NOT NULL,
  161. renewDate BIGINT NOT NULL,
  162. CONSTRAINT [pk_sequenceNum] PRIMARY KEY
  163. (
  164. [sequenceNum]
  165. )
  166. )
  167. SET ANSI_PADDING OFF
  168. PRINT 'Table delegationTokens created.'
  169. END
  170. ELSE
  171. PRINT 'Table delegationTokens exists, no operation required...'
  172. GO
  173. GO
  174. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  175. WHERE name = 'masterKeys'
  176. AND schema_id = SCHEMA_ID('dbo'))
  177. BEGIN
  178. PRINT 'Table masterKeys does not exist, create it...'
  179. SET ANSI_NULLS ON
  180. SET QUOTED_IDENTIFIER ON
  181. SET ANSI_PADDING ON
  182. CREATE TABLE [dbo].[masterKeys](
  183. keyId BIGINT NOT NULL,
  184. masterKey VARCHAR(1024) NOT NULL,
  185. CONSTRAINT [pk_keyId] PRIMARY KEY
  186. (
  187. [keyId]
  188. )
  189. )
  190. SET ANSI_PADDING OFF
  191. PRINT 'Table masterKeys created.'
  192. END
  193. ELSE
  194. PRINT 'Table masterKeys exists, no operation required...'
  195. GO
  196. GO
  197. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  198. WHERE name = 'delegationTokens'
  199. AND schema_id = SCHEMA_ID('dbo'))
  200. BEGIN
  201. PRINT 'Table delegationTokens does not exist, create it...'
  202. SET ANSI_NULLS ON
  203. SET QUOTED_IDENTIFIER ON
  204. SET ANSI_PADDING ON
  205. CREATE TABLE [dbo].[delegationTokens](
  206. sequenceNum BIGINT NOT NULL,
  207. tokenIdent VARCHAR(1024) NOT NULL,
  208. token VARCHAR(1024) NOT NULL,
  209. renewDate BIGINT NOT NULL,
  210. CONSTRAINT [pk_sequenceNum] PRIMARY KEY
  211. (
  212. [sequenceNum]
  213. )
  214. )
  215. SET ANSI_PADDING OFF
  216. PRINT 'Table delegationTokens created.'
  217. END
  218. ELSE
  219. PRINT 'Table delegationTokens exists, no operation required...'
  220. GO
  221. GO
  222. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  223. WHERE name = 'sequenceTable'
  224. AND schema_id = SCHEMA_ID('dbo'))
  225. BEGIN
  226. PRINT 'Table sequenceTable does not exist, create it...'
  227. SET ANSI_NULLS ON
  228. SET QUOTED_IDENTIFIER ON
  229. SET ANSI_PADDING ON
  230. CREATE TABLE [dbo].[sequenceTable](
  231. sequenceName VARCHAR(255) NOT NULL,
  232. nextVal bigint NOT NULL
  233. CONSTRAINT [pk_sequenceName] PRIMARY KEY
  234. (
  235. [sequenceName]
  236. )
  237. )
  238. SET ANSI_PADDING OFF
  239. PRINT 'Table sequenceTable created.'
  240. END
  241. ELSE
  242. PRINT 'Table sequenceTable exists, no operation required...'
  243. GO
  244. GO
  245. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  246. WHERE name = 'versions'
  247. AND schema_id = SCHEMA_ID('dbo'))
  248. BEGIN
  249. PRINT 'Table versions does not exist, create it...'
  250. SET ANSI_NULLS ON
  251. SET QUOTED_IDENTIFIER ON
  252. SET ANSI_PADDING ON
  253. CREATE TABLE [dbo].[versions](
  254. fedVersion VARBINARY(1024) NOT NULL,
  255. versionComment VARCHAR(255) NOT NULL
  256. CONSTRAINT [pk_fedVersion] PRIMARY KEY
  257. (
  258. [fedVersion]
  259. )
  260. )
  261. SET ANSI_PADDING OFF
  262. PRINT 'Table versions created.'
  263. END
  264. ELSE
  265. PRINT 'Table versions exists, no operation required...'
  266. GO
  267. GO