feat(waitlist): optional event waitlist with FIFO promote.
Commercial calendars opt in via settings.waitlist_enabled; join when full; auto-promote on cancel/decline/expire with email and in-app notify. Refs EventHub/EventHubBack#72
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
%% @doc Create waitlist_entry table and indexes (Back#72).
|
||||
-module('20260814193000_waitlist_entry').
|
||||
|
||||
-export([up/0, down/0]).
|
||||
|
||||
-include("records.hrl").
|
||||
|
||||
up() ->
|
||||
ensure_table(waitlist_entry, record_info(fields, waitlist_entry)),
|
||||
ensure_index(waitlist_entry, event_id),
|
||||
ensure_index(waitlist_entry, user_id),
|
||||
ensure_index(waitlist_entry, status),
|
||||
ok.
|
||||
|
||||
down() ->
|
||||
_ = mnesia:delete_table(waitlist_entry),
|
||||
ok.
|
||||
|
||||
ensure_table(Table, Attrs) ->
|
||||
case lists:member(Table, mnesia:system_info(tables)) of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
case mnesia:create_table(Table, [{disc_copies, [node()]}, {attributes, Attrs}]) of
|
||||
{atomic, ok} -> ok;
|
||||
{aborted, {already_exists, Table}} -> ok;
|
||||
{aborted, Reason} -> error({create_table_failed, Table, Reason})
|
||||
end
|
||||
end.
|
||||
|
||||
ensure_index(Table, Attr) ->
|
||||
case mnesia:add_table_index(Table, Attr) of
|
||||
{atomic, ok} -> ok;
|
||||
{aborted, {already_exists, Table, _Pos}} -> ok;
|
||||
{aborted, {already_exists, Table, Attr}} -> ok;
|
||||
{aborted, {already_exists, _}} -> ok;
|
||||
{aborted, Reason} -> error({add_index_failed, Table, Attr, Reason})
|
||||
end.
|
||||
Reference in New Issue
Block a user