Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove unneeded as any in migrations generator for enum #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/migrations/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
this.renameTable(model.name, model.oldName!);
});
tables[tables.indexOf(model.oldName)] = model.name;
this.columns[model.name] = this.columns[model.oldName]!;

Check warning on line 83 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 83 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
delete this.columns[model.oldName];

if (model.updatable) {
Expand All @@ -99,7 +99,7 @@
});
});
tables[tables.indexOf(`${model.oldName}Revision`)] = `${model.name}Revision`;
this.columns[`${model.name}Revision`] = this.columns[`${model.oldName}Revision`]!;

Check warning on line 102 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 102 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
delete this.columns[`${model.oldName}Revision`];
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@
model,
model.fields.filter(
({ name, relation, raw, foreignKey }) =>
!raw && !this.columns[model.name]!.some((col) => col.name === (foreignKey || (relation ? `${name}Id` : name)))

Check warning on line 134 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 134 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
),
up,
down
Expand All @@ -139,7 +139,7 @@

// Update fields
const existingFields = model.fields.filter(({ name, relation, nonNull }) => {
const col = this.columns[model.name]!.find((col) => col.name === (relation ? `${name}Id` : name));

Check warning on line 142 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 142 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
if (!col) {
return false;
}
Expand Down Expand Up @@ -197,7 +197,7 @@
({ name, relation, raw, foreignKey, updatable }) =>
!raw &&
updatable &&
!this.columns[revisionTable]!.some((col) => col.name === (foreignKey || (relation ? `${name}Id` : name)))

Check warning on line 200 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 200 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
);

this.createRevisionFields(model, missingRevisionFields, up, down);
Expand All @@ -208,7 +208,7 @@
!raw &&
!updatable &&
foreignKey !== 'id' &&
this.columns[revisionTable]!.some((col) => col.name === (foreignKey || (relation ? `${name}Id` : name)))

Check warning on line 211 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 211 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
);
this.createRevisionFields(model, revisionFieldsToRemove, down, up);
}
Expand All @@ -219,7 +219,7 @@
if (tables.includes(model.name)) {
this.createFields(
model,
model.fields.filter(({ name, deleted }) => deleted && this.columns[model.name]!.some((col) => col.name === name)),

Check warning on line 222 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 222 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
down,
up
);
Expand Down Expand Up @@ -363,7 +363,7 @@
this.column(
field,
{ alter: true },
summonByName(this.columns[model.name]!, field.relation ? `${field.name}Id` : field.name)

Check warning on line 366 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 366 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
);
}
});
Expand All @@ -389,7 +389,7 @@
this.column(
field,
{ alter: true },
summonByName(this.columns[model.name]!, field.relation ? `${field.name}Id` : field.name)

Check warning on line 392 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 18)

Forbidden non-null assertion

Check warning on line 392 in src/migrations/generate.ts

View workflow job for this annotation

GitHub Actions / test and build package (node 20)

Forbidden non-null assertion
);
}
});
Expand Down Expand Up @@ -583,7 +583,7 @@
list
? this.writer.write(`table.specificType('${name}', '"${typeToField(type)}"[]');`)
: this.writer
.write(`table.enum('${name}', null as any, `)
.write(`table.enum('${name}', null, `)
.inlineBlock(() => {
this.writer.writeLine(`useNative: true,`);
this.writer.writeLine(`existingType: true,`);
Expand Down
Loading