Coverage for watcher/db/sqlalchemy/alembic/versions/001_ocata.py: 65%

26 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1"""ocata release 

2 

3Revision ID: 9894235b4278 

4Revises: None 

5Create Date: 2017-02-01 09:40:05.065981 

6 

7""" 

8from alembic import op 

9import oslo_db 

10import sqlalchemy as sa 

11from watcher.db.sqlalchemy import models 

12 

13 

14# revision identifiers, used by Alembic. 

15revision = '001' 

16down_revision = None 

17 

18 

19def upgrade(): 

20 op.create_table( 

21 'goals', 

22 sa.Column('created_at', sa.DateTime(), nullable=True), 

23 sa.Column('updated_at', sa.DateTime(), nullable=True), 

24 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

25 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

26 nullable=True), 

27 sa.Column('id', sa.Integer(), nullable=False), 

28 sa.Column('uuid', sa.String(length=36), nullable=True), 

29 sa.Column('name', sa.String(length=63), nullable=False), 

30 sa.Column('display_name', sa.String(length=63), nullable=False), 

31 sa.Column('efficacy_specification', models.JSONEncodedList(), 

32 nullable=False), 

33 sa.PrimaryKeyConstraint('id'), 

34 sa.UniqueConstraint('name', 'deleted', name='uniq_goals0name'), 

35 sa.UniqueConstraint('uuid', name='uniq_goals0uuid') 

36 ) 

37 

38 op.create_table( 

39 'scoring_engines', 

40 sa.Column('created_at', sa.DateTime(), nullable=True), 

41 sa.Column('updated_at', sa.DateTime(), nullable=True), 

42 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

43 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

44 nullable=True), 

45 sa.Column('id', sa.Integer(), nullable=False), 

46 sa.Column('uuid', sa.String(length=36), nullable=False), 

47 sa.Column('name', sa.String(length=63), nullable=False), 

48 sa.Column('description', sa.String(length=255), nullable=True), 

49 sa.Column('metainfo', sa.Text(), nullable=True), 

50 sa.PrimaryKeyConstraint('id'), 

51 sa.UniqueConstraint('name', 'deleted', 

52 name='uniq_scoring_engines0name'), 

53 sa.UniqueConstraint('uuid', name='uniq_scoring_engines0uuid') 

54 ) 

55 

56 op.create_table( 

57 'services', 

58 sa.Column('created_at', sa.DateTime(), nullable=True), 

59 sa.Column('updated_at', sa.DateTime(), nullable=True), 

60 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

61 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

62 nullable=True), 

63 sa.Column('id', sa.Integer(), nullable=False), 

64 sa.Column('name', sa.String(length=255), nullable=False), 

65 sa.Column('host', sa.String(length=255), nullable=False), 

66 sa.Column('last_seen_up', sa.DateTime(), nullable=True), 

67 sa.PrimaryKeyConstraint('id'), 

68 sa.UniqueConstraint('host', 'name', 'deleted', 

69 name='uniq_services0host0name0deleted') 

70 ) 

71 

72 op.create_table( 

73 'strategies', 

74 sa.Column('created_at', sa.DateTime(), nullable=True), 

75 sa.Column('updated_at', sa.DateTime(), nullable=True), 

76 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

77 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

78 nullable=True), 

79 sa.Column('id', sa.Integer(), nullable=False), 

80 sa.Column('uuid', sa.String(length=36), nullable=True), 

81 sa.Column('name', sa.String(length=63), nullable=False), 

82 sa.Column('display_name', sa.String(length=63), nullable=False), 

83 sa.Column('goal_id', sa.Integer(), nullable=False), 

84 sa.Column('parameters_spec', models.JSONEncodedDict(), 

85 nullable=True), 

86 sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ), 

87 sa.PrimaryKeyConstraint('id'), 

88 sa.UniqueConstraint('name', 'deleted', name='uniq_strategies0name'), 

89 sa.UniqueConstraint('uuid', name='uniq_strategies0uuid') 

90 ) 

91 

92 op.create_table( 

93 'audit_templates', 

94 sa.Column('created_at', sa.DateTime(), nullable=True), 

95 sa.Column('updated_at', sa.DateTime(), nullable=True), 

96 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

97 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

98 nullable=True), 

99 sa.Column('id', sa.Integer(), nullable=False), 

100 sa.Column('uuid', sa.String(length=36), nullable=True), 

101 sa.Column('name', sa.String(length=63), nullable=True), 

102 sa.Column('description', sa.String(length=255), nullable=True), 

103 sa.Column('goal_id', sa.Integer(), nullable=False), 

104 sa.Column('strategy_id', sa.Integer(), nullable=True), 

105 sa.Column('scope', models.JSONEncodedList(), 

106 nullable=True), 

107 sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ), 

108 sa.ForeignKeyConstraint(['strategy_id'], ['strategies.id'], ), 

109 sa.PrimaryKeyConstraint('id'), 

110 sa.UniqueConstraint('name', 'deleted', 

111 name='uniq_audit_templates0name'), 

112 sa.UniqueConstraint('uuid', name='uniq_audit_templates0uuid') 

113 ) 

114 op.create_table( 

115 'audits', 

116 sa.Column('created_at', sa.DateTime(), nullable=True), 

117 sa.Column('updated_at', sa.DateTime(), nullable=True), 

118 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

119 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

120 nullable=True), 

121 sa.Column('id', sa.Integer(), nullable=False), 

122 sa.Column('uuid', sa.String(length=36), nullable=True), 

123 sa.Column('audit_type', sa.String(length=20), nullable=True), 

124 sa.Column('state', sa.String(length=20), nullable=True), 

125 sa.Column('parameters', models.JSONEncodedDict(), nullable=True), 

126 sa.Column('interval', sa.Integer(), nullable=True), 

127 sa.Column('goal_id', sa.Integer(), nullable=False), 

128 sa.Column('strategy_id', sa.Integer(), nullable=True), 

129 sa.Column('scope', models.JSONEncodedList(), nullable=True), 

130 sa.Column('auto_trigger', sa.Boolean(), nullable=False), 

131 sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ), 

132 sa.ForeignKeyConstraint(['strategy_id'], ['strategies.id'], ), 

133 sa.PrimaryKeyConstraint('id'), 

134 sa.UniqueConstraint('uuid', name='uniq_audits0uuid') 

135 ) 

136 op.create_table( 

137 'action_plans', 

138 sa.Column('created_at', sa.DateTime(), nullable=True), 

139 sa.Column('updated_at', sa.DateTime(), nullable=True), 

140 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

141 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

142 nullable=True), 

143 sa.Column('id', sa.Integer(), nullable=False), 

144 sa.Column('uuid', sa.String(length=36), nullable=True), 

145 sa.Column('audit_id', sa.Integer(), nullable=False), 

146 sa.Column('strategy_id', sa.Integer(), nullable=False), 

147 sa.Column('state', sa.String(length=20), nullable=True), 

148 sa.Column('global_efficacy', models.JSONEncodedDict(), nullable=True), 

149 sa.ForeignKeyConstraint(['audit_id'], ['audits.id'], ), 

150 sa.ForeignKeyConstraint(['strategy_id'], ['strategies.id'], ), 

151 sa.PrimaryKeyConstraint('id'), 

152 sa.UniqueConstraint('uuid', name='uniq_action_plans0uuid') 

153 ) 

154 

155 op.create_table( 

156 'actions', 

157 sa.Column('created_at', sa.DateTime(), nullable=True), 

158 sa.Column('updated_at', sa.DateTime(), nullable=True), 

159 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

160 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

161 nullable=True), 

162 sa.Column('id', sa.Integer(), nullable=False), 

163 sa.Column('uuid', sa.String(length=36), nullable=False), 

164 sa.Column('action_plan_id', sa.Integer(), nullable=False), 

165 sa.Column('action_type', sa.String(length=255), nullable=False), 

166 sa.Column('input_parameters', models.JSONEncodedDict(), nullable=True), 

167 sa.Column('state', sa.String(length=20), nullable=True), 

168 sa.Column('parents', models.JSONEncodedList(), nullable=True), 

169 sa.ForeignKeyConstraint(['action_plan_id'], ['action_plans.id'], ), 

170 sa.PrimaryKeyConstraint('id'), 

171 sa.UniqueConstraint('uuid', name='uniq_actions0uuid') 

172 ) 

173 

174 op.create_table( 

175 'efficacy_indicators', 

176 sa.Column('created_at', sa.DateTime(), nullable=True), 

177 sa.Column('updated_at', sa.DateTime(), nullable=True), 

178 sa.Column('deleted_at', sa.DateTime(), nullable=True), 

179 sa.Column('deleted', oslo_db.sqlalchemy.types.SoftDeleteInteger(), 

180 nullable=True), 

181 sa.Column('id', sa.Integer(), nullable=False), 

182 sa.Column('uuid', sa.String(length=36), nullable=True), 

183 sa.Column('name', sa.String(length=63), nullable=True), 

184 sa.Column('description', sa.String(length=255), nullable=True), 

185 sa.Column('unit', sa.String(length=63), nullable=True), 

186 sa.Column('value', sa.Numeric(), nullable=True), 

187 sa.Column('action_plan_id', sa.Integer(), nullable=False), 

188 sa.ForeignKeyConstraint(['action_plan_id'], ['action_plans.id'], ), 

189 sa.PrimaryKeyConstraint('id'), 

190 sa.UniqueConstraint('uuid', name='uniq_efficacy_indicators0uuid') 

191 ) 

192 

193 

194def downgrade(): 

195 op.drop_table('efficacy_indicators') 

196 op.drop_table('actions') 

197 op.drop_table('action_plans') 

198 op.drop_table('audits') 

199 op.drop_table('audit_templates') 

200 op.drop_table('strategies') 

201 op.drop_table('services') 

202 op.drop_table('scoring_engines') 

203 op.drop_table('goals')