feat: compute asset sha256 for dedupe
This commit is contained in:
12
packages/db/migrations/0007_asset_hashes.sql
Normal file
12
packages/db/migrations/0007_asset_hashes.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS asset_hashes (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
asset_id uuid NOT NULL REFERENCES assets(id) ON DELETE CASCADE,
|
||||
bucket text NOT NULL,
|
||||
sha256 text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS asset_hashes_asset_id_idx ON asset_hashes(asset_id);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS asset_hashes_bucket_sha256_idx
|
||||
ON asset_hashes(bucket, sha256) WHERE sha256 IS NOT NULL;
|
||||
Reference in New Issue
Block a user