-- admin account and its role and right
insert into "user" ("username", "password_hash")
values (
    'admin',
    '$2a$12$FChbwNEIH9imtkTAkNq35eqMb.1C.1BP3bbuFZwOr7rOrs5luwCzq'
  );

insert into "role" ("name")
values ('admin');

insert into "role_binding" ("user_id", "role_id")
values (
    (
      select "id"
      from "user"
      where "username" = 'admin'
    ),
    (
      select "id"
      from "role"
      where "name" = 'admin'
    )
  );

-- default channel
call add_channel('default', 'default channel');

-- member role
insert into "role" ("name")
values ('member');

insert into "right" ("role_id", "channel_id", "rights")
values (
    (
      select "id"
      from "role"
      where "name" = 'member'
    ),
    (
      select "id"
      from "channel"
      where "name" = 'default'
    ),
    'RW'
  );
