Spring Security(Third Edition)
上QQ阅读APP看书,第一时间看更新

The group-based schema

It may be obvious, but the first SQL file we added contains updates to the schema to support group-based authorization. You can find the contents of the file in the following code snippet:

    //src/main/resources/database/h2/security-groups-schema.sql

create table groups (
id bigint generated by default as identity(start with 0) primary key,
group_name varchar(256) not null
);
create table group_authorities (
group_id bigint not null,
authority varchar(256) not null,
constraint fk_group_authorities_group
foreign key(group_id) references groups(id)
);
create table group_members (
id bigint generated by default as identity(start with 0) primary key,
username varchar(256) not null,
group_id bigint not null,\
      constraint fk_group_members_group
foreign key(group_id) references groups(id)\
);