samsondav / rihanna

Rihanna is a high performance postgres-backed job queue for Elixir
MIT License
439 stars 47 forks source link

Option to create the jobs_table_name on a different schema #105

Open iceniveth opened 2 years ago

iceniveth commented 2 years ago

I did try to use a different schema from the jobs_table_name config.

config :rihanna, jobs_table_name: "edu.rihanna_jobs"

But right after executing mix ecto.migrate it ran into this error:

12:00:46.192 [info]  execute "CREATE TABLE edu.rihanna_jobs (\n  id int NOT NULL,\n  term bytea NOT NULL,\n  priority integer NOT NULL DEFAULT 50,\n  enqueued_at timestamp with time zone NOT NULL,\n  due_at timestamp with time zone,\n  failed_at timestamp with time zone,\n  fail_reason text,\n  rihanna_internal_meta jsonb NOT NULL DEFAULT '{}',\n  CONSTRAINT failed_at_required_fail_reason CHECK((failed_at IS NOT NULL AND fail_reason IS NOT NULL) OR (failed_at IS NULL and fail_reason IS NULL))\n);\n"

12:00:46.202 [info]  execute "COMMENT ON CONSTRAINT failed_at_required_fail_reason ON edu.rihanna_jobs IS 'When setting failed_at you must also set a fail_reason';\n"

12:00:46.203 [info]  execute "CREATE SEQUENCE edu.rihanna_jobs_id_seq\nSTART WITH 1\nINCREMENT BY 1\nMINVALUE 1\nMAXVALUE 2147483647\nCACHE 1\nCYCLE;\n"

12:00:46.207 [info]  execute "ALTER SEQUENCE edu.rihanna_jobs_id_seq OWNED BY edu.rihanna_jobs.id;\n"

12:00:46.208 [info]  execute "ALTER TABLE ONLY edu.rihanna_jobs ALTER COLUMN id SET DEFAULT nextval('edu.rihanna_jobs_id_seq'::regclass);\n"

12:00:46.209 [info]  execute "ALTER TABLE ONLY edu.rihanna_jobs\nADD CONSTRAINT edu.rihanna_jobs_pkey PRIMARY KEY (id);\n"
** (Postgrex.Error) ERROR 42601 (syntax_error) syntax error at or near "."

    query: ALTER TABLE ONLY edu.rihanna_jobs
ADD CONSTRAINT edu.rihanna_jobs_pkey PRIMARY KEY (id);

    (ecto_sql 3.5.1) lib/ecto/adapters/sql.ex:751: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.11.3) lib/enum.ex:1411: Enum."-map/2-lists^map/1-0-"/2
    (ecto_sql 3.5.1) lib/ecto/adapters/sql.ex:838: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.5.1) lib/ecto/migration/runner.ex:343: Ecto.Migration.Runner.log_and_execute_ddl/3
    (ecto_sql 3.5.1) lib/ecto/migration/runner.ex:117: anonymous fn/6 in Ecto.Migration.Runner.flush/0
    (elixir 1.11.3) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto_sql 3.5.1) lib/ecto/migration/runner.ex:116: Ecto.Migration.Runner.flush/0
    (ecto_sql 3.5.1) lib/ecto/migration/runner.ex:280: Ecto.Migration.Runner.perform_operation/3
    (stdlib 3.14.2) timer.erl:166: :timer.tc/1
    (ecto_sql 3.5.1) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/8
    (ecto_sql 3.5.1) lib/ecto/migrator.ex:349: Ecto.Migrator.attempt/8
    (ecto_sql 3.5.1) lib/ecto/migrator.ex:249: anonymous fn/5 in Ecto.Migrator.do_up/5
    (ecto_sql 3.5.1) lib/ecto/migrator.ex:331: anonymous fn/3 in Ecto.Migrator.run_maybe_in_transaction/6
    (ecto_sql 3.5.1) lib/ecto/adapters/sql.ex:1027: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.3.0) lib/db_connection.ex:1426: DBConnection.run_transaction/4
    (ecto_sql 3.5.1) lib/ecto/migrator.ex:330: Ecto.Migrator.run_maybe_in_transaction/6
    (elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.11.3) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.14.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

I guess it's not possible for now?

Would be great if we are able to place the job tables under a different schema 🙏