Skip to content

Commit

Permalink
Merge pull request #209 from dfpc-coe/video-lease
Browse files Browse the repository at this point in the history
Video Lease UI
  • Loading branch information
ingalls authored Jun 29, 2024
2 parents de4c5de + a32229c commit f2c0f86
Show file tree
Hide file tree
Showing 127 changed files with 7,979 additions and 1,591 deletions.
3 changes: 3 additions & 0 deletions api/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default class Models {
ProfileOverlay: Modeler<typeof pgtypes.ProfileOverlay>;
ProfileMission: Modeler<typeof pgtypes.ProfileMission>;

VideoLease: Modeler<typeof pgtypes.VideoLease>;

Task: Modeler<typeof pgtypes.Task>;

Iconset: Modeler<typeof pgtypes.Iconset>;
Expand All @@ -49,6 +51,7 @@ export default class Models {
this.ProfileMission = new Modeler(pg, pgtypes.ProfileMission);
this.Basemap = new Modeler(pg, pgtypes.Basemap);
this.Import = new Modeler(pg, pgtypes.Import);
this.VideoLease = new Modeler(pg, pgtypes.VideoLease);
this.Connection = new Modeler(pg, pgtypes.Connection);
this.ConnectionToken = new Modeler(pg, pgtypes.ConnectionToken);
this.ConnectionSink = new Modeler(pg, pgtypes.ConnectionSink);
Expand Down
10 changes: 10 additions & 0 deletions api/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export const ProfileChat = pgTable('profile_chats', {
message: text('message').notNull()
});

export const VideoLease = pgTable('video_lease', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
created: timestamp('created', { withTimezone: true, mode: 'string' }).notNull().default(sql`Now()`),
updated: timestamp('updated', { withTimezone: true, mode: 'string' }).notNull().default(sql`Now()`),
username: text('username').notNull().references(() => Profile.username),
expiration: timestamp('expiration', { withTimezone: true, mode: 'string' }).notNull().default(sql`Now() + INTERVAL 1 HOUR;`),
path: text('path').notNull()
});

export const ProfileFeature = pgTable('profile_features', {
id: text('id').primaryKey(),
path: text('path').notNull().default('/'),
Expand Down
4 changes: 4 additions & 0 deletions api/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export const ProfileResponse = Type.Object({
display_speed: Type.String()
});

export const VideoLeaseResponse = createSelectSchema(schemas.VideoLease, {
id: Type.Integer(),
});

export const OverlayResponse = createSelectSchema(schemas.Overlay, {
id: Type.Integer(),
});
Expand Down
31 changes: 31 additions & 0 deletions api/migrations/0048_illegal_betty_ross.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE TABLE IF NOT EXISTS "video_lease" (
"id" serial PRIMARY KEY NOT NULL,
"created" timestamp with time zone DEFAULT Now() NOT NULL,
"updated" timestamp with time zone DEFAULT Now() NOT NULL,
"username" text NOT NULL,
"expiration" timestamp with time zone DEFAULT Now() + INTERVAL '1 HOUR' NOT NULL,
"path" text NOT NULL
);
--> statement-breakpoint
/*
Unfortunately in current drizzle-kit version we can't automatically get name for primary key.
We are working on making it available!
Meanwhile you can:
1. Check pk name in your database, by running
SELECT constraint_name FROM information_schema.table_constraints
WHERE table_schema = 'public'
AND table_name = 'tasks'
AND constraint_type = 'PRIMARY KEY';
2. Uncomment code below and paste pk name manually
Hope to release this update as soon as possible
*/

DO $$ BEGIN
ALTER TABLE "video_lease" ADD CONSTRAINT "video_lease_username_profile_username_fk" FOREIGN KEY ("username") REFERENCES "public"."profile"("username") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_prefix_unique" UNIQUE("prefix");
1 change: 1 addition & 0 deletions api/migrations/0049_silly_blink.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "video_lease" ADD COLUMN "name" text NOT NULL;
Loading

0 comments on commit f2c0f86

Please sign in to comment.