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. applicationContext VARBINARY(MAX) NULL,
  33. CONSTRAINT [pk_applicationId] PRIMARY KEY
  34. (
  35. [applicationId]
  36. )
  37. )
  38. SET ANSI_PADDING OFF
  39. PRINT 'Table applicationsHomeSubCluster created.'
  40. END
  41. ELSE
  42. PRINT 'Table applicationsHomeSubCluster exists, no operation required...'
  43. GO
  44. GO
  45. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  46. WHERE name = 'membership'
  47. AND schema_id = SCHEMA_ID('dbo'))
  48. BEGIN
  49. PRINT 'Table membership does not exist, create it...'
  50. SET ANSI_NULLS ON
  51. SET QUOTED_IDENTIFIER ON
  52. SET ANSI_PADDING ON
  53. CREATE TABLE [dbo].[membership](
  54. [subClusterId] VARCHAR(256) COLLATE Latin1_General_100_BIN2 NOT NULL,
  55. [amRMServiceAddress] VARCHAR(256) NOT NULL,
  56. [clientRMServiceAddress] VARCHAR(256) NOT NULL,
  57. [rmAdminServiceAddress] VARCHAR(256) NOT NULL,
  58. [rmWebServiceAddress] VARCHAR(256) NOT NULL,
  59. [lastHeartBeat] DATETIME2 NOT NULL,
  60. [state] VARCHAR(32) NOT NULL,
  61. [lastStartTime] BIGINT NOT NULL,
  62. [capability] VARCHAR(6000) NOT NULL,
  63. CONSTRAINT [pk_subClusterId] PRIMARY KEY
  64. (
  65. [subClusterId]
  66. ),
  67. CONSTRAINT [uc_lastStartTime] UNIQUE
  68. (
  69. [lastStartTime]
  70. )
  71. )
  72. SET ANSI_PADDING OFF
  73. PRINT 'Table membership created.'
  74. END
  75. ELSE
  76. PRINT 'Table membership exists, no operation required...'
  77. GO
  78. GO
  79. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  80. WHERE name = 'policies'
  81. AND schema_id = SCHEMA_ID('dbo'))
  82. BEGIN
  83. PRINT 'Table policies does not exist, create it...'
  84. SET ANSI_NULLS ON
  85. SET QUOTED_IDENTIFIER ON
  86. SET ANSI_PADDING ON
  87. CREATE TABLE [dbo].[policies](
  88. queue VARCHAR(256) COLLATE Latin1_General_100_BIN2 NOT NULL,
  89. policyType VARCHAR(256) NOT NULL,
  90. params VARBINARY(6000) NOT NULL,
  91. CONSTRAINT [pk_queue] PRIMARY KEY
  92. (
  93. [queue]
  94. )
  95. )
  96. SET ANSI_PADDING OFF
  97. PRINT 'Table policies created.'
  98. END
  99. ELSE
  100. PRINT 'Table policies exists, no operation required...'
  101. GO
  102. GO
  103. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  104. WHERE name = 'reservationsHomeSubCluster'
  105. AND schema_id = SCHEMA_ID('dbo'))
  106. BEGIN
  107. PRINT 'Table reservationsHomeSubCluster does not exist, create it...'
  108. SET ANSI_NULLS ON
  109. SET QUOTED_IDENTIFIER ON
  110. SET ANSI_PADDING ON
  111. CREATE TABLE [dbo].[reservationsHomeSubCluster](
  112. reservationId VARCHAR(128) COLLATE Latin1_General_100_BIN2 NOT NULL,
  113. homeSubCluster VARCHAR(256) NOT NULL,
  114. createTime DATETIME2 NOT NULL CONSTRAINT ts_createResTime DEFAULT GETUTCDATE(),
  115. CONSTRAINT [pk_reservationId] PRIMARY KEY
  116. (
  117. [reservationId]
  118. )
  119. )
  120. SET ANSI_PADDING OFF
  121. PRINT 'Table reservationsHomeSubCluster created.'
  122. END
  123. ELSE
  124. PRINT 'Table reservationsHomeSubCluster exists, no operation required...'
  125. GO
  126. GO
  127. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  128. WHERE name = 'masterKeys'
  129. AND schema_id = SCHEMA_ID('dbo'))
  130. BEGIN
  131. PRINT 'Table masterKeys does not exist, create it...'
  132. SET ANSI_NULLS ON
  133. SET QUOTED_IDENTIFIER ON
  134. SET ANSI_PADDING ON
  135. CREATE TABLE [dbo].[masterKeys](
  136. keyId BIGINT NOT NULL,
  137. masterKey VARCHAR(1024) NOT NULL,
  138. CONSTRAINT [pk_keyId] PRIMARY KEY
  139. (
  140. [keyId]
  141. )
  142. )
  143. SET ANSI_PADDING OFF
  144. PRINT 'Table masterKeys created.'
  145. END
  146. ELSE
  147. PRINT 'Table masterKeys exists, no operation required...'
  148. GO
  149. GO
  150. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  151. WHERE name = 'delegationTokens'
  152. AND schema_id = SCHEMA_ID('dbo'))
  153. BEGIN
  154. PRINT 'Table delegationTokens does not exist, create it...'
  155. SET ANSI_NULLS ON
  156. SET QUOTED_IDENTIFIER ON
  157. SET ANSI_PADDING ON
  158. CREATE TABLE [dbo].[delegationTokens](
  159. sequenceNum BIGINT NOT NULL,
  160. tokenIdent VARCHAR(1024) NOT NULL,
  161. token VARCHAR(1024) NOT NULL,
  162. renewDate BIGINT NOT NULL,
  163. CONSTRAINT [pk_sequenceNum] PRIMARY KEY
  164. (
  165. [sequenceNum]
  166. )
  167. )
  168. SET ANSI_PADDING OFF
  169. PRINT 'Table delegationTokens created.'
  170. END
  171. ELSE
  172. PRINT 'Table delegationTokens exists, no operation required...'
  173. GO
  174. GO
  175. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  176. WHERE name = 'masterKeys'
  177. AND schema_id = SCHEMA_ID('dbo'))
  178. BEGIN
  179. PRINT 'Table masterKeys does not exist, create it...'
  180. SET ANSI_NULLS ON
  181. SET QUOTED_IDENTIFIER ON
  182. SET ANSI_PADDING ON
  183. CREATE TABLE [dbo].[masterKeys](
  184. keyId BIGINT NOT NULL,
  185. masterKey VARCHAR(1024) NOT NULL,
  186. CONSTRAINT [pk_keyId] PRIMARY KEY
  187. (
  188. [keyId]
  189. )
  190. )
  191. SET ANSI_PADDING OFF
  192. PRINT 'Table masterKeys created.'
  193. END
  194. ELSE
  195. PRINT 'Table masterKeys exists, no operation required...'
  196. GO
  197. GO
  198. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  199. WHERE name = 'delegationTokens'
  200. AND schema_id = SCHEMA_ID('dbo'))
  201. BEGIN
  202. PRINT 'Table delegationTokens does not exist, create it...'
  203. SET ANSI_NULLS ON
  204. SET QUOTED_IDENTIFIER ON
  205. SET ANSI_PADDING ON
  206. CREATE TABLE [dbo].[delegationTokens](
  207. sequenceNum BIGINT NOT NULL,
  208. tokenIdent VARCHAR(1024) NOT NULL,
  209. token VARCHAR(1024) NOT NULL,
  210. renewDate BIGINT NOT NULL,
  211. CONSTRAINT [pk_sequenceNum] PRIMARY KEY
  212. (
  213. [sequenceNum]
  214. )
  215. )
  216. SET ANSI_PADDING OFF
  217. PRINT 'Table delegationTokens created.'
  218. END
  219. ELSE
  220. PRINT 'Table delegationTokens exists, no operation required...'
  221. GO
  222. GO
  223. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  224. WHERE name = 'sequenceTable'
  225. AND schema_id = SCHEMA_ID('dbo'))
  226. BEGIN
  227. PRINT 'Table sequenceTable does not exist, create it...'
  228. SET ANSI_NULLS ON
  229. SET QUOTED_IDENTIFIER ON
  230. SET ANSI_PADDING ON
  231. CREATE TABLE [dbo].[sequenceTable](
  232. sequenceName VARCHAR(255) NOT NULL,
  233. nextVal bigint NOT NULL
  234. CONSTRAINT [pk_sequenceName] PRIMARY KEY
  235. (
  236. [sequenceName]
  237. )
  238. )
  239. SET ANSI_PADDING OFF
  240. PRINT 'Table sequenceTable created.'
  241. END
  242. ELSE
  243. PRINT 'Table sequenceTable exists, no operation required...'
  244. GO
  245. GO
  246. IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
  247. WHERE name = 'versions'
  248. AND schema_id = SCHEMA_ID('dbo'))
  249. BEGIN
  250. PRINT 'Table versions does not exist, create it...'
  251. SET ANSI_NULLS ON
  252. SET QUOTED_IDENTIFIER ON
  253. SET ANSI_PADDING ON
  254. CREATE TABLE [dbo].[versions](
  255. fedVersion VARBINARY(1024) NOT NULL,
  256. versionComment VARCHAR(255) NOT NULL
  257. CONSTRAINT [pk_fedVersion] PRIMARY KEY
  258. (
  259. [fedVersion]
  260. )
  261. )
  262. SET ANSI_PADDING OFF
  263. PRINT 'Table versions created.'
  264. END
  265. ELSE
  266. PRINT 'Table versions exists, no operation required...'
  267. GO
  268. GO