mirror of
https://github.com/djhackersdev/minime.git
synced 2026-08-28 13:34:03 -05:00
Fix SQL column capitalization
This commit is contained in:
@@ -32,9 +32,9 @@ create table "idz"."chara" (
|
||||
"field_04" integer not null,
|
||||
"field_06" integer not null,
|
||||
"field_08" integer not null,
|
||||
"field_0A" integer not null,
|
||||
"field_0C" integer not null,
|
||||
"field_0E" integer not null,
|
||||
"field_0a" integer not null,
|
||||
"field_0c" integer not null,
|
||||
"field_0e" integer not null,
|
||||
"title" integer not null,
|
||||
"background" integer not null
|
||||
);
|
||||
@@ -60,15 +60,15 @@ create table "idz"."car" (
|
||||
"field_04" integer[] not null,
|
||||
"field_46" integer not null,
|
||||
"field_48" integer not null,
|
||||
"field_4A" integer not null,
|
||||
"field_4C" integer not null,
|
||||
"field_4a" integer not null,
|
||||
"field_4c" integer not null,
|
||||
"field_50_lo" integer not null,
|
||||
"field_50_hi" integer not null,
|
||||
"field_58" integer not null,
|
||||
"field_5A" integer not null,
|
||||
"field_5B" integer not null,
|
||||
"field_5C" integer not null,
|
||||
"field_5E" integer not null,
|
||||
"field_5a" integer not null,
|
||||
"field_5b" integer not null,
|
||||
"field_5c" integer not null,
|
||||
"field_5e" integer not null,
|
||||
constraint "car_uq" unique ("profile_id", "selector")
|
||||
);
|
||||
|
||||
|
||||
21
schema/migrate/M0004-idz-fix-col-casing.sql
Normal file
21
schema/migrate/M0004-idz-fix-col-casing.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Fun story: PostgreSQL (can't speak for other dbs) doesn't actually treat
|
||||
-- its column and table names case-insensitively. It forces them to lower-
|
||||
-- case instead. If you quote an upper-case field name then it will be upper-
|
||||
-- case in the database and you will need to use quoted upper-case every time
|
||||
-- you want to access it.
|
||||
|
||||
-- It is likely that people will find this behavior surprising, to say the
|
||||
-- least. We'll change the column names so that they are always lower-case.
|
||||
|
||||
alter table "idz"."chara" rename column "field_0A" to "field_0a";
|
||||
alter table "idz"."chara" rename column "field_0C" to "field_0c";
|
||||
alter table "idz"."chara" rename column "field_0E" to "field_0e";
|
||||
|
||||
alter table "idz"."car" rename column "field_4A" to "field_4a";
|
||||
alter table "idz"."car" rename column "field_4C" to "field_4c";
|
||||
alter table "idz"."car" rename column "field_5A" to "field_5a";
|
||||
alter table "idz"."car" rename column "field_5B" to "field_5b";
|
||||
alter table "idz"."car" rename column "field_5C" to "field_5c";
|
||||
alter table "idz"."car" rename column "field_5E" to "field_5e";
|
||||
|
||||
update "meta" set "schemaver" = 3;
|
||||
@@ -3,7 +3,7 @@ import { Pool, PoolClient } from "pg";
|
||||
|
||||
export type Id<T> = bigint & { __id: T };
|
||||
|
||||
const currentSchemaVer = 2;
|
||||
const currentSchemaVer = 3;
|
||||
|
||||
const pool = new Pool();
|
||||
const fence = testConnection();
|
||||
|
||||
@@ -14,15 +14,15 @@ function _extractRow(row: any): Car {
|
||||
field_04: row.field_04,
|
||||
field_46: row.field_46,
|
||||
field_48: row.field_48,
|
||||
field_4A: row.field_4A,
|
||||
field_4C: row.field_4C,
|
||||
field_4a: row.field_4a,
|
||||
field_4c: row.field_4c,
|
||||
field_50_lo: row.field_50_lo,
|
||||
field_50_hi: row.field_50_hi,
|
||||
field_58: row.field_58,
|
||||
field_5A: row.field_5A,
|
||||
field_5B: row.field_5B,
|
||||
field_5C: row.field_5C,
|
||||
field_5E: row.field_5E,
|
||||
field_5a: row.field_5a,
|
||||
field_5b: row.field_5b,
|
||||
field_5c: row.field_5c,
|
||||
field_5e: row.field_5e,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -78,15 +78,15 @@ export class SqlCarRepository implements CarRepository {
|
||||
field_04: car.field_04,
|
||||
field_46: car.field_46,
|
||||
field_48: car.field_48,
|
||||
field_4A: car.field_4A,
|
||||
field_4C: car.field_4C,
|
||||
field_4a: car.field_4a,
|
||||
field_4c: car.field_4c,
|
||||
field_50_lo: car.field_50_lo,
|
||||
field_50_hi: car.field_50_hi,
|
||||
field_58: car.field_58,
|
||||
field_5A: car.field_5A,
|
||||
field_5B: car.field_5B,
|
||||
field_5C: car.field_5C,
|
||||
field_5E: car.field_5E,
|
||||
field_5a: car.field_5a,
|
||||
field_5b: car.field_5b,
|
||||
field_5c: car.field_5c,
|
||||
field_5e: car.field_5e,
|
||||
})
|
||||
.onConflict("profile_id", "selector")
|
||||
.doUpdate([
|
||||
@@ -95,15 +95,15 @@ export class SqlCarRepository implements CarRepository {
|
||||
"field_04",
|
||||
"field_46",
|
||||
"field_48",
|
||||
"field_4A",
|
||||
"field_4C",
|
||||
"field_4a",
|
||||
"field_4c",
|
||||
"field_50_lo",
|
||||
"field_50_hi",
|
||||
"field_58",
|
||||
"field_5A",
|
||||
"field_5B",
|
||||
"field_5C",
|
||||
"field_5E",
|
||||
"field_5a",
|
||||
"field_5b",
|
||||
"field_5c",
|
||||
"field_5e",
|
||||
])
|
||||
.toParams();
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ export function _extractChara(row: any): Chara {
|
||||
field_04: row.field_04,
|
||||
field_06: row.field_06,
|
||||
field_08: row.field_08,
|
||||
field_0A: row.field_0A,
|
||||
field_0C: row.field_0C,
|
||||
field_0E: row.field_0E,
|
||||
field_0a: row.field_0a,
|
||||
field_0c: row.field_0c,
|
||||
field_0e: row.field_0e,
|
||||
title: row.title,
|
||||
background: row.background,
|
||||
};
|
||||
@@ -46,9 +46,9 @@ export class SqlCharaRepository implements FacetRepository<Chara> {
|
||||
field_04: chara.field_04,
|
||||
field_06: chara.field_06,
|
||||
field_08: chara.field_08,
|
||||
field_0A: chara.field_0A,
|
||||
field_0C: chara.field_0C,
|
||||
field_0E: chara.field_0E,
|
||||
field_0a: chara.field_0a,
|
||||
field_0c: chara.field_0c,
|
||||
field_0e: chara.field_0e,
|
||||
title: chara.title,
|
||||
background: chara.background,
|
||||
})
|
||||
@@ -58,9 +58,9 @@ export class SqlCharaRepository implements FacetRepository<Chara> {
|
||||
"field_04",
|
||||
"field_06",
|
||||
"field_08",
|
||||
"field_0A",
|
||||
"field_0C",
|
||||
"field_0E",
|
||||
"field_0a",
|
||||
"field_0c",
|
||||
"field_0e",
|
||||
"title",
|
||||
"background",
|
||||
])
|
||||
|
||||
@@ -14,14 +14,14 @@ export function car(buf: Buffer): Car {
|
||||
selector: buf.readUInt16LE(0x0044) as CarSelector,
|
||||
field_46: buf.readUInt16LE(0x0046),
|
||||
field_48: buf.readUInt16LE(0x0048),
|
||||
field_4A: buf.readUInt16LE(0x004a),
|
||||
field_4C: buf.readUInt32LE(0x004c),
|
||||
field_4a: buf.readUInt16LE(0x004a),
|
||||
field_4c: buf.readUInt32LE(0x004c),
|
||||
field_50_lo: buf.readUInt32LE(0x0050),
|
||||
field_50_hi: buf.readUInt32LE(0x0054),
|
||||
field_58: buf.readUInt16LE(0x0058),
|
||||
field_5A: buf.readUInt8(0x005a),
|
||||
field_5B: buf.readUInt8(0x005b),
|
||||
field_5C: buf.readUInt16LE(0x005c),
|
||||
field_5E: buf.readUInt16LE(0x005e),
|
||||
field_5a: buf.readUInt8(0x005a),
|
||||
field_5b: buf.readUInt8(0x005b),
|
||||
field_5c: buf.readUInt16LE(0x005c),
|
||||
field_5e: buf.readUInt16LE(0x005e),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ export function chara(buf: Buffer): Chara {
|
||||
field_04: buf.readUInt16LE(0x04),
|
||||
field_06: buf.readUInt16LE(0x06),
|
||||
field_08: buf.readUInt16LE(0x08),
|
||||
field_0A: buf.readUInt16LE(0x0a),
|
||||
field_0C: buf.readUInt16LE(0x0c),
|
||||
field_0E: buf.readUInt16LE(0x0e),
|
||||
field_0a: buf.readUInt16LE(0x0a),
|
||||
field_0c: buf.readUInt16LE(0x0c),
|
||||
field_0e: buf.readUInt16LE(0x0e),
|
||||
title: buf.readUInt16LE(0x10) as TitleCode, // Swapped on load
|
||||
background: buf.readUInt16LE(0x12) as BackgroundCode, // Swapped on load
|
||||
};
|
||||
|
||||
@@ -16,15 +16,15 @@ export function encodeCar(car: Car): Buffer {
|
||||
buf.writeUInt16LE(car.selector, 0x0044);
|
||||
buf.writeUInt16LE(car.field_46, 0x0046);
|
||||
buf.writeUInt16LE(car.field_48, 0x0048);
|
||||
buf.writeUInt16LE(car.field_4A, 0x004a);
|
||||
buf.writeUInt32LE(car.field_4C, 0x004c);
|
||||
buf.writeUInt16LE(car.field_4a, 0x004a);
|
||||
buf.writeUInt32LE(car.field_4c, 0x004c);
|
||||
buf.writeUInt32LE(car.field_50_lo, 0x0050);
|
||||
buf.writeUInt32LE(car.field_50_hi, 0x0054);
|
||||
buf.writeUInt16LE(car.field_58, 0x0058);
|
||||
buf.writeUInt8(car.field_5A, 0x005a);
|
||||
buf.writeUInt8(car.field_5B, 0x005b);
|
||||
buf.writeUInt16LE(car.field_5C, 0x005c);
|
||||
buf.writeUInt16LE(car.field_5E, 0x005e);
|
||||
buf.writeUInt8(car.field_5a, 0x005a);
|
||||
buf.writeUInt8(car.field_5b, 0x005b);
|
||||
buf.writeUInt16LE(car.field_5c, 0x005c);
|
||||
buf.writeUInt16LE(car.field_5e, 0x005e);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ export function encodeChara(chara: Chara): Buffer {
|
||||
buf.writeUInt16LE(chara.field_04, 0x04);
|
||||
buf.writeUInt16LE(chara.field_06, 0x06);
|
||||
buf.writeUInt16LE(chara.field_08, 0x08);
|
||||
buf.writeUInt16LE(chara.field_0A, 0x0a);
|
||||
buf.writeUInt16LE(chara.field_0C, 0x0c);
|
||||
buf.writeUInt16LE(chara.field_0E, 0x0e);
|
||||
buf.writeUInt16LE(chara.field_0a, 0x0a);
|
||||
buf.writeUInt16LE(chara.field_0c, 0x0c);
|
||||
buf.writeUInt16LE(chara.field_0e, 0x0e);
|
||||
buf.writeUInt16LE(chara.background, 0x10); // Swapped on save
|
||||
buf.writeUInt16LE(chara.title, 0x12); // Swapped on save
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ export interface Car {
|
||||
selector: CarSelector;
|
||||
field_46: number;
|
||||
field_48: number;
|
||||
field_4A: number;
|
||||
field_4C: number;
|
||||
field_4a: number;
|
||||
field_4c: number;
|
||||
field_50_lo: number;
|
||||
field_50_hi: number;
|
||||
field_58: number;
|
||||
field_5A: number;
|
||||
field_5B: number;
|
||||
field_5C: number;
|
||||
field_5E: number;
|
||||
field_5a: number;
|
||||
field_5b: number;
|
||||
field_5c: number;
|
||||
field_5e: number;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ export interface Chara {
|
||||
field_04: number;
|
||||
field_06: number;
|
||||
field_08: number;
|
||||
field_0A: number;
|
||||
field_0C: number;
|
||||
field_0E: number;
|
||||
field_0a: number;
|
||||
field_0c: number;
|
||||
field_0e: number;
|
||||
title: TitleCode;
|
||||
background: BackgroundCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user