feat: add resources to technology schema, improve version display, and introduce migration for resource costs on technologies
This commit is contained in:
parent
d3fbb48422
commit
9426f12574
6 changed files with 9171 additions and 8 deletions
|
|
@ -52,10 +52,6 @@ export const Technologies: CollectionConfig = {
|
|||
name: "requirements",
|
||||
type: "group",
|
||||
fields: [
|
||||
{
|
||||
name: "intelligencePoints",
|
||||
type: "number",
|
||||
},
|
||||
{
|
||||
name: "prerequisiteTechnologies",
|
||||
type: "array",
|
||||
|
|
@ -107,6 +103,24 @@ export const Technologies: CollectionConfig = {
|
|||
name: "researchCosts",
|
||||
type: "group",
|
||||
fields: [
|
||||
{
|
||||
name: "resources",
|
||||
type: "array",
|
||||
fields: [
|
||||
{
|
||||
name: "resource",
|
||||
type: "relationship",
|
||||
relationTo: "resources",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "amount",
|
||||
type: "number",
|
||||
defaultValue: 1,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "row",
|
||||
fields: [
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const VersionOverlay = () => {
|
|||
<div className="fixed top-0 z-9999 w-full flex justify-center">
|
||||
<div className="text-white flex flex-col items-center justify-between bg-red-950 w-fit px-2 rounded-b group overflow-hidden">
|
||||
<span className="text-center text-sm pointer-events-none">
|
||||
version {appVersion ?? "Unknown version"}
|
||||
{appVersion ? `version ${appVersion}` : "unknown version"}
|
||||
</span>
|
||||
{appLastUpdated && (
|
||||
<span className="text-center text-xs h-0 group-hover:h-full pointer-events-none transition-all duration-100 ease-in-out">
|
||||
|
|
|
|||
9106
src/migrations/20251223_055859.json
Normal file
9106
src/migrations/20251223_055859.json
Normal file
File diff suppressed because it is too large
Load diff
25
src/migrations/20251223_055859.ts
Normal file
25
src/migrations/20251223_055859.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||
|
||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
CREATE TABLE "technologies_research_costs_resources" (
|
||||
"_order" integer NOT NULL,
|
||||
"_parent_id" integer NOT NULL,
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"resource_id" integer NOT NULL,
|
||||
"amount" numeric DEFAULT 1 NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE "technologies_research_costs_resources" ADD CONSTRAINT "technologies_research_costs_resources_resource_id_resources_id_fk" FOREIGN KEY ("resource_id") REFERENCES "public"."resources"("id") ON DELETE set null ON UPDATE no action;
|
||||
ALTER TABLE "technologies_research_costs_resources" ADD CONSTRAINT "technologies_research_costs_resources_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."technologies"("id") ON DELETE cascade ON UPDATE no action;
|
||||
CREATE INDEX "technologies_research_costs_resources_order_idx" ON "technologies_research_costs_resources" USING btree ("_order");
|
||||
CREATE INDEX "technologies_research_costs_resources_parent_id_idx" ON "technologies_research_costs_resources" USING btree ("_parent_id");
|
||||
CREATE INDEX "technologies_research_costs_resources_resource_idx" ON "technologies_research_costs_resources" USING btree ("resource_id");
|
||||
ALTER TABLE "technologies" DROP COLUMN "requirements_intelligence_points";`)
|
||||
}
|
||||
|
||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
DROP TABLE "technologies_research_costs_resources" CASCADE;
|
||||
ALTER TABLE "technologies" ADD COLUMN "requirements_intelligence_points" numeric;`)
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ import * as migration_20251206_065831 from './20251206_065831';
|
|||
import * as migration_20251212_183607 from './20251212_183607';
|
||||
import * as migration_20251219_061127 from './20251219_061127';
|
||||
import * as migration_20251222_200320 from './20251222_200320';
|
||||
import * as migration_20251223_055859 from './20251223_055859';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
|
|
@ -22,6 +23,11 @@ export const migrations = [
|
|||
{
|
||||
up: migration_20251222_200320.up,
|
||||
down: migration_20251222_200320.down,
|
||||
name: '20251222_200320'
|
||||
name: '20251222_200320',
|
||||
},
|
||||
{
|
||||
up: migration_20251223_055859.up,
|
||||
down: migration_20251223_055859.down,
|
||||
name: '20251223_055859'
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -533,7 +533,6 @@ export interface Technology {
|
|||
[k: string]: unknown;
|
||||
} | null;
|
||||
requirements?: {
|
||||
intelligencePoints?: number | null;
|
||||
prerequisiteTechnologies?:
|
||||
| {
|
||||
/**
|
||||
|
|
@ -553,6 +552,13 @@ export interface Technology {
|
|||
| null;
|
||||
};
|
||||
researchCosts: {
|
||||
resources?:
|
||||
| {
|
||||
resource: number | Resource;
|
||||
amount: number;
|
||||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
/**
|
||||
* The minimum amount of time in minutes that it takes to research this technology. If no maximum duration is provided, this technology will be researched in an amount of time exactly equal to this number.
|
||||
*/
|
||||
|
|
@ -1772,7 +1778,6 @@ export interface TechnologiesSelect<T extends boolean = true> {
|
|||
requirements?:
|
||||
| T
|
||||
| {
|
||||
intelligencePoints?: T;
|
||||
prerequisiteTechnologies?:
|
||||
| T
|
||||
| {
|
||||
|
|
@ -1792,6 +1797,13 @@ export interface TechnologiesSelect<T extends boolean = true> {
|
|||
researchCosts?:
|
||||
| T
|
||||
| {
|
||||
resources?:
|
||||
| T
|
||||
| {
|
||||
resource?: T;
|
||||
amount?: T;
|
||||
id?: T;
|
||||
};
|
||||
minimumResearchDuration?: T;
|
||||
maximumResearchDuration?: T;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue