Skip to content

Instantly share code, notes, and snippets.

@cannium
Last active November 27, 2019 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cannium/fbf2336ca1b99b8d1eb3c91346c1d198 to your computer and use it in GitHub Desktop.
Save cannium/fbf2336ca1b99b8d1eb3c91346c1d198 to your computer and use it in GitHub Desktop.
yig DB schema review
drop table if exists clusters;
create table clusters (
id varchar(64) not null default '',
pool varchar(16) not null default '',
weight int not null default 0,
primary key (id, pool)
);
drop table if exists buckets;
create table buckets (
name varchar(64) not null primary key default '' comment 'bucket name',
acl tinyint not null default 0
comment 'canned ACL,
0.private 1.public-read 2.public-read-write 3.aws-exec-read
4.authenticated-read 5.bucket-owner-read 6.bucket-owner-full-control
7.log-delivery-write
see https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html',
-- fancy ACL?
policy json not null comment 'bucket policy',
cors json not null,
lifecycle json not null,
uid varchar(128) not null default '' comment 'owner IAM user ID',
website json not null,
data_size bigint unsigned not null default 0
comment 'total object size(byte) in this bucket',
versioning tinyint not null default 0
comment 'bucket versioning status,
0.disabled 1.enabled 2.suspended',
created_at datetime not null default CURRENT_TIMESTAMP
);
drop table if exists objects;
create table objects (
id bigint unsigned not null auto_increment primary key,
bucket varchar(64) not null default '' comment 'bucket name',
name varbinary(1024) not null default '' comment 'object name',
version bigint not null default 0
comment '0 for null version, < 0 for delete marker, otherwise version number',
backend tinyint not null default 0
comment 'backend type, 0.ceph 1.seaweedfs',
cluster varchar(64) not null default '' comment 'storage backend cluster id',
pool varchar(16) not null default '',
internal_oid varchar(128) not null default '' comment 'object id at storage backend',
uid varchar(128) not null default '' comment 'owner IAM user ID',
size bigint unsigned not null default 0 comment 'size in bytes',
etag varchar(64) not null default '',
content_type varchar(128) not null default '',
custom_attributes json not null,
acl tinyint not null default 0
comment 'canned ACL,
0.private 1.public-read 2.public-read-write 3.aws-exec-read
4.authenticated-read 5.bucket-owner-read 6.bucket-owner-full-control
7.log-delivery-write
see https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html',
-- fancy ACL?
sse_type tinyint not null default 0
comment 'server-side encryption(SSE) type,
0.disabled 1.SSE-S3 2.SSE-KMS 3.SSE-C
see https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html',
encryption_key varbinary(64) not null default '',
iv varbinary(32) not null default '' comment 'encryption initialization vector(IV)',
upload_type tinyint not null default 0
comment 'object upload type,
0.normal 1.appendable 2.multipart 3.multipart(uploading)',
storage_class tinyint not null default 0
comment '0.STANDARD 1.STANDARD_IA 2.INTELLIGENT_TIERING 3.ONEZONE_IA
4.GLACIER 5.DEEP_ARCHIVE 6.RRS',
created_at datetime not null default CURRENT_TIMESTAMP
comment 'create time at user`s perspective',
updated_at datetime not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
comment 'metadata update time'
);
create unique index uniq_bucket_object_version on objects(bucket, name, version);
create index idx_create_at on objects(created_at);
drop table if exists parts;
create table parts (
object_id bigint unsigned not null comment 'id in objects table',
internal_id varchar(128) not null default '' comment 'object id at storage backend',
part_number int not null default 0,
size bigint unsigned not null default 0 comment 'part size in byte',
offset bigint not null default 0 comment 'offset in the whole object',
etag varchar(64) not null default '',
iv varbinary(32) not null default '' comment 'encryption initialization vector(IV)',
updated_at datetime not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
primary key (object_id, part_number)
);
@cannium
Copy link
Author

cannium commented Nov 27, 2019

Currently parts point to object, we might need an object pointing to its parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment