Skip to content

Commit f1c45d5

Browse files
Cleanup after the orgId on videos backfill (#1136)
* make `orgId` required * make `orgId` required in Effect
1 parent 99770b9 commit f1c45d5

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

packages/database/schema.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const nanoId = customType<{ data: string; notNull: true }>({
2424
return `varchar(${nanoIdLength})`;
2525
},
2626
});
27+
// TODO: This will replace `nanoId` in: https://github.com/CapSoftware/Cap/pull/1105
28+
const nanoIdRequired = (name: string) =>
29+
varchar(name, { length: nanoIdLength }).notNull();
2730

2831
const nanoIdNullable = customType<{ data: string; notNull: false }>({
2932
dataType() {
@@ -247,8 +250,7 @@ export const videos = mysqlTable(
247250
{
248251
id: nanoId("id").notNull().primaryKey().unique().$type<Video.VideoId>(),
249252
ownerId: nanoId("ownerId").notNull(),
250-
// TODO: make this non-null
251-
orgId: nanoIdNullable("orgId"),
253+
orgId: nanoIdRequired("orgId"),
252254
name: varchar("name", { length: 255 }).notNull().default("My Video"),
253255
bucket: nanoIdNullable("bucket").$type<S3Bucket.S3BucketId>(),
254256
// in seconds

packages/web-backend/src/Loom/ImportVideo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const LoomImportVideoLive = LoomImportVideo.toLayer(
7070

7171
const videoId = yield* videos.create({
7272
ownerId: payload.cap.userId,
73-
orgId: Option.some(payload.cap.orgId),
73+
orgId: payload.cap.orgId,
7474
bucketId: customBucketId,
7575
source: { type: "desktopMP4" as const },
7676
name: payload.loom.video.name,

packages/web-backend/src/Videos/VideosRepo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class VideosRepo extends Effect.Service<VideosRepo>()("VideosRepo", {
5858
{
5959
...data,
6060
id,
61-
orgId: Option.getOrNull(data.orgId ?? Option.none()),
61+
orgId: data.orgId,
6262
bucket: Option.getOrNull(data.bucketId ?? Option.none()),
6363
metadata: Option.getOrNull(data.metadata ?? Option.none()),
6464
transcriptionStatus: Option.getOrNull(
@@ -72,12 +72,12 @@ export class VideosRepo extends Effect.Service<VideosRepo>()("VideosRepo", {
7272
]),
7373
];
7474

75-
if (data.importSource && Option.isSome(data.orgId))
75+
if (data.importSource)
7676
promises.push(
7777
db.insert(Db.importedVideos).values([
7878
{
7979
id,
80-
orgId: data.orgId.value,
80+
orgId: data.orgId,
8181
source: data.importSource.source,
8282
sourceId: data.importSource.id,
8383
},

packages/web-domain/src/Video.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type VideoId = typeof VideoId.Type;
1414
export class Video extends Schema.Class<Video>("Video")({
1515
id: VideoId,
1616
ownerId: Schema.String,
17-
orgId: Schema.OptionFromNullOr(Schema.String),
17+
orgId: Schema.String,
1818
name: Schema.String,
1919
public: Schema.Boolean,
2020
source: Schema.Struct({

0 commit comments

Comments
 (0)