in src/blob/persistence/SqlBlobMetadataStore.ts [127:376]
public async init(): Promise<void> {
await this.sequelize.authenticate();
ServicesModel.init(
{
accountName: {
type: "VARCHAR(32)",
primaryKey: true
},
defaultServiceVersion: {
type: "VARCHAR(10)"
},
cors: {
type: "VARCHAR(4095)"
},
logging: {
type: "VARCHAR(255)"
},
minuteMetrics: {
type: "VARCHAR(255)"
},
hourMetrics: {
type: "VARCHAR(255)"
},
staticWebsite: {
type: "VARCHAR(1023)"
},
deleteRetentionPolicy: {
type: "VARCHAR(255)"
}
},
{
sequelize: this.sequelize,
modelName: "Services",
tableName: "Services",
timestamps: false
}
);
ContainersModel.init(
{
accountName: {
type: "VARCHAR(32)",
unique: "accountname_containername"
},
// tslint:disable-next-line:max-line-length
// https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata
containerName: {
type: "VARCHAR(63)",
unique: "accountname_containername"
},
containerId: {
type: INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
lastModified: {
allowNull: false,
type: DATE(6)
},
etag: {
allowNull: false,
type: "VARCHAR(127)"
},
// TODO: Confirm max length of metadata pairs
metadata: {
type: "VARCHAR(4095)"
},
containerAcl: {
type: "VARCHAR(1023)"
},
publicAccess: {
type: "VARCHAR(31)"
},
lease: {
type: "VARCHAR(1023)"
},
hasImmutabilityPolicy: {
type: BOOLEAN
},
hasLegalHold: {
type: BOOLEAN
}
},
{
sequelize: this.sequelize,
modelName: "Containers",
tableName: "Containers",
charset: DEFAULT_SQL_CHARSET,
collate: DEFAULT_SQL_COLLATE,
timestamps: false
}
);
BlobsModel.init(
{
accountName: {
type: "VARCHAR(64)",
allowNull: false
},
containerName: {
type: "VARCHAR(255)",
allowNull: false
},
blobName: {
type: "VARCHAR(255)",
allowNull: false
},
snapshot: {
type: "VARCHAR(64)",
allowNull: false,
defaultValue: ""
},
blobId: {
type: INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
lastModified: {
allowNull: false,
type: DATE(6)
},
creationTime: {
allowNull: false,
type: DATE(6)
},
accessTierChangeTime: {
allowNull: true,
type: DATE(6)
},
accessTierInferred: {
type: BOOLEAN
},
etag: {
allowNull: false,
type: "VARCHAR(127)"
},
blobType: {
allowNull: false,
type: "VARCHAR(31)"
},
blobSequenceNumber: {
type: "VARCHAR(63)"
},
accessTier: {
type: "VARCHAR(31)"
},
contentProperties: {
type: "VARCHAR(1023)"
},
lease: {
type: "VARCHAR(1023)"
},
deleting: {
type: INTEGER.UNSIGNED,
defaultValue: 0, // 0 means container is not under deleting(gc)
allowNull: false
},
isCommitted: {
type: BOOLEAN,
allowNull: false
},
persistency: {
type: "VARCHAR(255)"
},
committedBlocksInOrder: {
type: TEXT({ length: "medium" })
},
metadata: {
type: "VARCHAR(2047)"
},
blobTags: {
type: "VARCHAR(4096)"
}
},
{
sequelize: this.sequelize,
modelName: "Blobs",
tableName: "Blobs",
timestamps: false,
charset: DEFAULT_SQL_CHARSET,
collate: DEFAULT_SQL_COLLATE,
indexes: [
{
// name: 'title_index',
// using: 'BTREE',
unique: true,
fields: [
"accountName",
"containerName",
"blobName",
"snapshot",
"deleting"
]
}
]
}
);
BlocksModel.init(
{
accountName: {
type: "VARCHAR(64)",
allowNull: false
},
containerName: {
type: "VARCHAR(255)",
allowNull: false
},
blobName: {
type: "VARCHAR(255)",
allowNull: false
},
// TODO: Check max block name length
blockName: {
type: "VARCHAR(64)",
allowNull: false
},
deleting: {
type: INTEGER.UNSIGNED,
defaultValue: 0, // 0 means container is not under deleting(gc)
allowNull: false
},
size: {
type: INTEGER.UNSIGNED,
allowNull: false
},
persistency: {
type: "VARCHAR(255)"
}
},
{
sequelize: this.sequelize,
modelName: "Blocks",
tableName: "Blocks",
timestamps: false,
indexes: [
{
unique: true,
fields: ["accountName", "containerName", "blobName", "blockName"]
}
]
}
);
// TODO: sync() is only for development purpose, use migration for production
await this.sequelize.sync();
this.initialized = true;
}