-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The object store will require tracking the underlying blobs of the object store. To do this we need to keep track of the path, size and hash. The path needs to be unique so multiple files are not added, the hash is not unqiue as multiple metadata can point to the same blob.
- Loading branch information
1 parent
39cb3f1
commit ab33404
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2023 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package schema | ||
|
||
import "github.com/juju/juju/core/database/schema" | ||
|
||
// objectStoreMetadataSchema provides a helper function for generating a change_log ddl | ||
// for a schema. | ||
func objectStoreMetadataSchema() schema.Patch { | ||
return schema.MakePatch(` | ||
CREATE TABLE object_store_metadata_hash_type ( | ||
id INT PRIMARY KEY, | ||
hash_type TEXT NOT NULL | ||
); | ||
CREATE UNIQUE INDEX idx_object_store_metadata_hash_type_name | ||
ON object_store_metadata_hash_type (hash_type); | ||
INSERT INTO object_store_metadata_hash_type VALUES | ||
(0, 'none'), | ||
(1, 'sha-256'); | ||
CREATE TABLE object_store_metadata ( | ||
uuid TEXT PRIMARY KEY, | ||
hash_type_id INT NOT NULL, | ||
hash TEXT, | ||
CONSTRAINT fk_object_store_metadata_hash_type | ||
FOREIGN KEY (hash_type_id) | ||
REFERENCES object_store_metadata_hash_type(id) | ||
); | ||
CREATE UNIQUE INDEX idx_object_store_metadata_hash ON object_store_metadata (hash); | ||
CREATE TABLE object_store_metadata_path ( | ||
uuid TEXT PRIMARY KEY, | ||
metadata_uuid TEXT NOT NULL, | ||
path TEXT NOT NULL, | ||
size INT NOT NULL, | ||
CONSTRAINT fk_object_store_metadata_metadata_uuid | ||
FOREIGN KEY (metadata_uuid) | ||
REFERENCES object_store_metadata(uuid) | ||
); | ||
CREATE UNIQUE INDEX idx_object_store_metadata_path ON object_store_metadata_path (path); | ||
`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters