Skip to content

Commit 43f37ba

Browse files
committed
feat(github_hooks): add zebra migrations
1 parent 968d284 commit 43f37ba

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddExpiresAtToJobs < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :jobs, :expires_at, :datetime
4+
end
5+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddExpiresCreatedIndexAtJobsTable < ActiveRecord::Migration[6.1]
2+
disable_ddl_transaction!
3+
4+
def change
5+
add_index :jobs,
6+
%i[expires_at created_at],
7+
name: "index_jobs_on_expires_created_not_null",
8+
algorithm: :concurrently,
9+
where: "expires_at IS NOT NULL"
10+
end
11+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddOrganizationCreatedIndexAtJobsTable < ActiveRecord::Migration[6.1]
2+
disable_ddl_transaction!
3+
4+
def change
5+
add_index :jobs,
6+
%i[organization_id created_at],
7+
name: "index_jobs_on_organization_created_expires_is_null",
8+
algorithm: :concurrently,
9+
where: "expires_at IS NULL"
10+
end
11+
end

zebra/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ ZEBRA_CALLBACK_TOKEN_KEYS?="testing"
3636
CONTAINER_ENV_VARS= \
3737
-e CI=$(CI) \
3838
-e MIX_ENV=$(MIX_ENV) \
39+
-e START_JOB_DELETION_POLICY_MARKER=$(START_JOB_DELETION_POLICY_MARKER) \
40+
-e START_JOB_DELETION_POLICY_WORKER=$(START_JOB_DELETION_POLICY_WORKER) \
3941
-e START_PUBLIC_JOB_API=$(START_PUBLIC_JOB_API) \
4042
-e START_INTERNAL_JOB_API=$(START_INTERNAL_JOB_API) \
4143
-e START_INTERNAL_TASK_API=$(START_INTERNAL_TASK_API) \

zebra/test/zebra/workers_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ defmodule Zebra.Workers.Test do
33

44
test "no environment variables set => only default workers start" do
55
assert Zebra.Workers.active() == [
6-
Zebra.Workers.JobDeletionPolicyWorker,
76
Zebra.FeatureProviderInvalidatorWorker
87
]
98
end
@@ -13,16 +12,21 @@ defmodule Zebra.Workers.Test do
1312
System.put_env("START_JOB_STOPPER", "true")
1413
System.put_env("START_TASK_FAIL_FAST_WORKER", "true")
1514
System.put_env("START_TASK_FINISHER_WORKER", "true")
15+
System.put_env("START_JOB_DELETION_POLICY_MARKER", "true")
16+
System.put_env("START_JOB_DELETION_POLICY_WORKER", "true")
1617

1718
on_exit(fn ->
1819
System.put_env("START_JOB_STOPPER", "false")
1920
System.put_env("START_TASK_FAIL_FAST_WORKER", "false")
2021
System.put_env("START_TASK_FINISHER_WORKER", "false")
22+
System.put_env("START_JOB_DELETION_POLICY_MARKER", "false")
23+
System.put_env("START_JOB_DELETION_POLICY_WORKER", "false")
2124
end)
2225
end
2326

2427
test "active workers are returned" do
2528
assert Zebra.Workers.active() == [
29+
Zebra.Workers.JobDeletionPolicyMarker,
2630
Zebra.Workers.JobDeletionPolicyWorker,
2731
Zebra.Workers.TaskFinisher,
2832
Zebra.Workers.TaskFailFast,

0 commit comments

Comments
 (0)