Browse Source

Add a migration to create the scheduled_jobs table

This commit adds a required migration and additionally creates a
new field in the model called 'scheduler_id'.

Change-Id: I5436e34dec032b9028221e3e87c8d88a9b207e23
tags/9.0.0.0b1
Mike Fedosin 2 months ago
parent
commit
21f95a5873

+ 54
- 0
mistral/db/sqlalchemy/migration/alembic_migrations/versions/034_add_scheduled_jobs_table.py View File

@@ -0,0 +1,54 @@
1
+# Copyright 2019 OpenStack Foundation.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#    http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+# implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+
16
+"""Create scheduled jobs table.
17
+
18
+Revision ID: 034
19
+Revises: 033
20
+Create Date: 2019-07-01 17:38:41.153354
21
+
22
+"""
23
+from alembic import op
24
+import sqlalchemy as sa
25
+
26
+from mistral.db.sqlalchemy import types as st
27
+
28
+# revision identifiers, used by Alembic.
29
+revision = '034'
30
+down_revision = '033'
31
+
32
+
33
+def upgrade():
34
+    op.create_table(
35
+        'scheduled_jobs_v2',
36
+        sa.Column('created_at', sa.DateTime(), nullable=True),
37
+        sa.Column('updated_at', sa.DateTime(), nullable=True),
38
+        sa.Column('id', sa.String(length=36), nullable=False),
39
+        sa.Column('run_after', sa.Integer(), nullable=True),
40
+        sa.Column(
41
+            'target_factory_func_name',
42
+            sa.String(length=200),
43
+            nullable=True
44
+        ),
45
+        sa.Column('func_name', sa.String(length=80), nullable=True),
46
+        sa.Column('func_args', st.JsonEncoded(), nullable=True),
47
+        sa.Column('func_arg_serializers', st.JsonEncoded(), nullable=True),
48
+        sa.Column('auth_ctx', st.JsonEncoded(), nullable=True),
49
+        sa.Column('execute_at', sa.DateTime(), nullable=False),
50
+        sa.Column('captured_at', sa.DateTime(), nullable=True),
51
+        sa.Column('key', sa.String(length=250), nullable=True),
52
+
53
+        sa.PrimaryKeyConstraint('id'),
54
+    )

+ 0
- 10
mistral/db/v2/sqlalchemy/models.py View File

@@ -460,16 +460,6 @@ class ScheduledJob(mb.MistralModelBase):
460 460
     key = sa.Column(sa.String(250), nullable=True)
461 461
 
462 462
 
463
-sa.Index(
464
-    '%s_execute_at' % ScheduledJob.__tablename__,
465
-    ScheduledJob.execute_at
466
-)
467
-sa.Index(
468
-    '%s_captured_at' % ScheduledJob.__tablename__,
469
-    ScheduledJob.captured_at
470
-)
471
-
472
-
473 463
 class Environment(mb.MistralSecureModelBase):
474 464
     """Contains environment variables for workflow execution."""
475 465
 

Loading…
Cancel
Save