create table
  public.member_user (
    id bigserial,
    nickname character varying(30) null default ''::character varying,
    name character varying(30) null,
    sex smallint null,
    birthday timestamp without time zone null,
    area_id integer null,
    mark character varying(255) null,
    point integer null default 0,
    avatar character varying(255) null default ''::character varying,
    status smallint not null default '1'::smallint,
    mobile character varying(11) null default ''''''::character varying,
    password character varying(100) not null default ''::character varying,
    register_ip character varying(32) null default ''''''::character varying,
    login_ip character varying(50) null default ''::character varying,
    login_date timestamp without time zone null,
    tag_ids character varying(255) null,
    level_id bigint null,
    experience bigint null,
    group_id bigint null,
    creator character varying(64) null default ''::character varying,
    create_time timestamp without time zone not null default current_timestamp,
    updater character varying(64) null default ''::character varying,
    update_time timestamp without time zone not null default current_timestamp,
    deleted boolean not null default false,
    tenant_id bigint not null default 0,
    user_id uuid not null,
    cardno character varying null,
    certificationnumber character varying null,
    dept_ids bigint[] null,
    role_ids bigint[] null,
    avatar_file jsonb null,
    constraint member_user_pkey1 primary key (user_id),
    constraint member_user_id_key unique (id),
    constraint unique_user_id unique (user_id),
    constraint member_user_user_id_fkey foreign key (user_id) references users (id)
  ) tablespace pg_default;

  create table
  public.ak_users (
    id uuid not null default gen_random_uuid (),
    username character varying(64) not null,
    email character varying(128) not null,
    password_hash character varying(256) not null default gen_random_uuid (),
    gender character varying(16) null default 'other'::character varying,
    birthday date null,
    height_cm integer null,
    weight_kg integer null,
    avatar_url text null,
    region_id uuid null,
    school_id uuid null,
    grade_id uuid null,
    class_id uuid null,
    role character varying(32) null default 'student'::character varying,
    created_at timestamp with time zone null default now(),
    updated_at timestamp with time zone null default now(),
    auth_id uuid null,
    preferred_language uuid null,
    bio text null,
    phone text null,
    constraint ak_users_pkey primary key (id),
    constraint ak_users_email_key unique (email),
    constraint ak_users_grade_id_fkey foreign key (grade_id) references ak_grades (id),
    constraint ak_users_preferred_language_fkey foreign key (preferred_language) references ak_languages (id),
    constraint ak_users_region_id_fkey foreign key (region_id) references ak_regions (id),
    constraint ak_users_auth_id_fkey foreign key (auth_id) references users (id) on delete cascade,
    constraint ak_users_school_id_fkey foreign key (school_id) references ak_schools (id),
    constraint ak_users_class_id_fkey foreign key (class_id) references ak_classes (id)
  ) tablespace pg_default;

create index if not exists idx_users_region_id on public.ak_users using btree (region_id) tablespace pg_default;

create index if not exists idx_users_school_id on public.ak_users using btree (school_id) tablespace pg_default;

create index if not exists idx_users_grade_id on public.ak_users using btree (grade_id) tablespace pg_default;

create index if not exists idx_users_class_id on public.ak_users using btree (class_id) tablespace pg_default;

create trigger tr_create_user_message_preferences
after insert on ak_users for each row
execute function create_default_message_preferences ();