mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat: Working on backend storage providers.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE "storage_policy" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"storage_channel_id" uuid NOT NULL,
|
||||
"enabled" boolean DEFAULT true NOT NULL,
|
||||
"database_id" uuid NOT NULL,
|
||||
"updated_at" timestamp,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||
"deleted_at" timestamp
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "storage_policy" ADD CONSTRAINT "storage_policy_storage_channel_id_storage_channel_id_fk" FOREIGN KEY ("storage_channel_id") REFERENCES "public"."storage_channel"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "storage_policy" ADD CONSTRAINT "storage_policy_database_id_databases_id_fk" FOREIGN KEY ("database_id") REFERENCES "public"."databases"("id") ON DELETE cascade ON UPDATE no action;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -148,6 +148,13 @@
|
||||
"when": 1768248015695,
|
||||
"tag": "0020_thankful_sunspot",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 21,
|
||||
"version": "7",
|
||||
"when": 1768337434929,
|
||||
"tag": "0021_soft_blockbuster",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {pgTable, text, boolean, timestamp, uuid, integer, pgEnum, uniqueIndex} from "drizzle-orm/pg-core";
|
||||
import {pgTable, text, boolean, timestamp, uuid, integer, pgEnum} from "drizzle-orm/pg-core";
|
||||
import {Agent, agent} from "./08_agent";
|
||||
import {Project, project} from "./06_project";
|
||||
import {relations} from "drizzle-orm";
|
||||
@@ -6,11 +6,8 @@ import {dbmsEnum, statusEnum} from "./types";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {timestamps} from "@/db/schema/00_common";
|
||||
import {member} from "@/db/schema/04_member";
|
||||
import {invitation} from "@/db/schema/05_invitation";
|
||||
import {organizationNotificationChannel} from "@/db/schema/09_notification-channel";
|
||||
import {organization} from "@/db/schema/03_organization";
|
||||
import {AlertPolicy, alertPolicy} from "@/db/schema/10_alert-policy";
|
||||
import {StoragePolicy, storagePolicy} from "@/db/schema/13_storage-policy";
|
||||
|
||||
export const database = pgTable("databases", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
@@ -84,6 +81,7 @@ export const databaseRelations = relations(database, ({one, many}) => ({
|
||||
backups: many(backup),
|
||||
restorations: many(restoration),
|
||||
alertPolicies: many(alertPolicy),
|
||||
storagePolicies: many(storagePolicy),
|
||||
}));
|
||||
|
||||
export const backupRelations = relations(backup, ({one, many}) => ({
|
||||
@@ -124,5 +122,6 @@ export type DatabaseWith = Database & {
|
||||
restorations?: Restoration[] | null;
|
||||
retentionPolicy?: RetentionPolicy | null;
|
||||
alertPolicies?: AlertPolicy[] | null;
|
||||
storagePolicies?: StoragePolicy[] | null;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import {boolean, pgTable, uuid} from "drizzle-orm/pg-core";
|
||||
import {timestamps} from "@/db/schema/00_common";
|
||||
import {relations} from "drizzle-orm";
|
||||
import {database} from "@/db/schema/07_database";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
import {storageChannel} from "@/db/schema/12_storage-channel";
|
||||
|
||||
export const storagePolicy = pgTable('storage_policy', {
|
||||
id: uuid('id').defaultRandom().primaryKey(),
|
||||
storageChannelId: uuid('storage_channel_id')
|
||||
.notNull()
|
||||
.references(() => storageChannel.id, {onDelete: 'cascade'}),
|
||||
enabled: boolean('enabled').default(true).notNull(),
|
||||
databaseId: uuid('database_id')
|
||||
.notNull()
|
||||
.references(() => database.id, {onDelete: 'cascade'}),
|
||||
...timestamps
|
||||
});
|
||||
|
||||
export const storagePolicyRelations = relations(storagePolicy, ({one}) => ({
|
||||
storageChannel: one(storageChannel, {
|
||||
fields: [storagePolicy.storageChannelId],
|
||||
references: [storageChannel.id],
|
||||
}),
|
||||
database: one(database, {
|
||||
fields: [storagePolicy.databaseId],
|
||||
references: [database.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const storagePolicySchema = createSelectSchema(storagePolicy);
|
||||
export type StoragePolicy = z.infer<typeof storagePolicySchema>;
|
||||
Reference in New Issue
Block a user