交付 Windows 与 Web 端到端加密附件预览
This commit is contained in:
1 parent
d1efdedc57
commit
c24960d22a
19 files changed
+421
-58
No files matched your search
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE device_attachments (
|
||||
id uuid PRIMARY KEY,
|
||||
sender_device uuid NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
|
||||
recipient_device uuid NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
|
||||
ciphertext bytea NOT NULL CHECK (octet_length(ciphertext) BETWEEN 16 AND 8388624),
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
CHECK (sender_device <> recipient_device)
|
||||
);
|
||||
|
||||
CREATE INDEX device_attachments_expiry ON device_attachments(created_at);
|
||||
@@ -22,6 +22,9 @@ var keyPackagesMigration string
|
||||
//go:embed 005_mls_credentials.sql
|
||||
var mlsCredentialsMigration string
|
||||
|
||||
//go:embed 006_attachments.sql
|
||||
var attachmentsMigration string
|
||||
|
||||
func Migrate(ctx context.Context, pool *pgxpool.Pool) error {
|
||||
tx, err := pool.Begin(ctx)
|
||||
if err != nil {
|
||||
@@ -34,7 +37,7 @@ func Migrate(ctx context.Context, pool *pgxpool.Pool) error {
|
||||
if _, err = tx.Exec(ctx, "CREATE TABLE IF NOT EXISTS schema_migrations (version integer PRIMARY KEY)"); err != nil {
|
||||
return err
|
||||
}
|
||||
for index, migration := range []string{identityMigration, contactsMigration, deliveryMigration, keyPackagesMigration, mlsCredentialsMigration} {
|
||||
for index, migration := range []string{identityMigration, contactsMigration, deliveryMigration, keyPackagesMigration, mlsCredentialsMigration, attachmentsMigration} {
|
||||
version := index + 1
|
||||
var applied bool
|
||||
if err = tx.QueryRow(ctx, "SELECT EXISTS (SELECT 1 FROM schema_migrations WHERE version=$1)", version).Scan(&applied); err != nil {
|
||||
|
||||
Reference in new issue
Block a user