feat: add Comuni, Provincie, and Nazioni tables with primary keys and indexes; update PublicSchema to include new tables
This commit is contained in:
parent
db174cf4f4
commit
f2c7bcce4e
5 changed files with 135 additions and 0 deletions
58
apps/db/migrations/25_comuni_provincie_nazioni.up.sql
Normal file
58
apps/db/migrations/25_comuni_provincie_nazioni.up.sql
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
-- Comuni Table
|
||||||
|
CREATE TABLE IF NOT EXISTS public.comuni (
|
||||||
|
id serial NOT NULL,
|
||||||
|
nome TEXT NOT NULL,
|
||||||
|
sigla TEXT NOT NULL,
|
||||||
|
catasto TEXT NOT NULL,
|
||||||
|
);
|
||||||
|
-- Primary Key
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE public.comuni
|
||||||
|
ADD CONSTRAINT comuni_pkey PRIMARY KEY (id);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN invalid_table_definition THEN
|
||||||
|
RAISE NOTICE 'Primary key already exists. Ignoring...';
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_comuni_nome ON comuni (nome);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_comuni_sigla ON comuni (sigla);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_comuni_nome_sigla ON comuni (nome, sigla);
|
||||||
|
|
||||||
|
-- Provincie Table
|
||||||
|
CREATE TABLE IF NOT EXISTS public.provincie (
|
||||||
|
id serial NOT NULL,
|
||||||
|
nome TEXT NOT NULL,
|
||||||
|
sigla TEXT NOT NULL,
|
||||||
|
);
|
||||||
|
-- Primary Key
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE public.provincie
|
||||||
|
ADD CONSTRAINT provincie_pkey PRIMARY KEY (id);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN invalid_table_definition THEN
|
||||||
|
RAISE NOTICE 'Primary key already exists. Ignoring...';
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_provincie_sigla ON provincie (sigla);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_provincie_nome ON provincie (nome);
|
||||||
|
|
||||||
|
-- Nazioni Table
|
||||||
|
CREATE TABLE IF NOT EXISTS public.nazioni (
|
||||||
|
id serial NOT NULL,
|
||||||
|
nome TEXT NOT NULL,
|
||||||
|
catasto TEXT NOT NULL,
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Primary Key
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE public.nazioni
|
||||||
|
ADD CONSTRAINT nazioni_pkey PRIMARY KEY (id);
|
||||||
|
EXCEPTION
|
||||||
|
WHEN invalid_table_definition THEN
|
||||||
|
RAISE NOTICE 'Primary key already exists. Ignoring...';
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_nazioni_nome ON nazioni (nome);
|
||||||
24
apps/infoalloggi/src/schemas/public/Comuni.ts
Normal file
24
apps/infoalloggi/src/schemas/public/Comuni.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// @generated
|
||||||
|
// This file is automatically generated by Kanel. Do not modify manually.
|
||||||
|
|
||||||
|
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||||
|
|
||||||
|
/** Identifier type for public.comuni */
|
||||||
|
export type ComuniId = number & { __brand: 'public.comuni' };
|
||||||
|
|
||||||
|
/** Represents the table public.comuni */
|
||||||
|
export default interface ComuniTable {
|
||||||
|
id: ColumnType<ComuniId, ComuniId | undefined, ComuniId>;
|
||||||
|
|
||||||
|
nome: ColumnType<string, string, string>;
|
||||||
|
|
||||||
|
sigla: ColumnType<string, string, string>;
|
||||||
|
|
||||||
|
catasto: ColumnType<string, string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Comuni = Selectable<ComuniTable>;
|
||||||
|
|
||||||
|
export type NewComuni = Insertable<ComuniTable>;
|
||||||
|
|
||||||
|
export type ComuniUpdate = Updateable<ComuniTable>;
|
||||||
22
apps/infoalloggi/src/schemas/public/Nazioni.ts
Normal file
22
apps/infoalloggi/src/schemas/public/Nazioni.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// @generated
|
||||||
|
// This file is automatically generated by Kanel. Do not modify manually.
|
||||||
|
|
||||||
|
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||||
|
|
||||||
|
/** Identifier type for public.nazioni */
|
||||||
|
export type NazioniId = number & { __brand: 'public.nazioni' };
|
||||||
|
|
||||||
|
/** Represents the table public.nazioni */
|
||||||
|
export default interface NazioniTable {
|
||||||
|
id: ColumnType<NazioniId, NazioniId | undefined, NazioniId>;
|
||||||
|
|
||||||
|
nome: ColumnType<string, string, string>;
|
||||||
|
|
||||||
|
catasto: ColumnType<string, string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Nazioni = Selectable<NazioniTable>;
|
||||||
|
|
||||||
|
export type NewNazioni = Insertable<NazioniTable>;
|
||||||
|
|
||||||
|
export type NazioniUpdate = Updateable<NazioniTable>;
|
||||||
22
apps/infoalloggi/src/schemas/public/Provincie.ts
Normal file
22
apps/infoalloggi/src/schemas/public/Provincie.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// @generated
|
||||||
|
// This file is automatically generated by Kanel. Do not modify manually.
|
||||||
|
|
||||||
|
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
||||||
|
|
||||||
|
/** Identifier type for public.provincie */
|
||||||
|
export type ProvincieId = number & { __brand: 'public.provincie' };
|
||||||
|
|
||||||
|
/** Represents the table public.provincie */
|
||||||
|
export default interface ProvincieTable {
|
||||||
|
id: ColumnType<ProvincieId, ProvincieId | undefined, ProvincieId>;
|
||||||
|
|
||||||
|
nome: ColumnType<string, string, string>;
|
||||||
|
|
||||||
|
sigla: ColumnType<string, string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Provincie = Selectable<ProvincieTable>;
|
||||||
|
|
||||||
|
export type NewProvincie = Insertable<ProvincieTable>;
|
||||||
|
|
||||||
|
export type ProvincieUpdate = Updateable<ProvincieTable>;
|
||||||
|
|
@ -11,6 +11,7 @@ import type { default as UsersStorageTable } from './UsersStorage';
|
||||||
import type { default as ServizioAnnunciTable } from './ServizioAnnunci';
|
import type { default as ServizioAnnunciTable } from './ServizioAnnunci';
|
||||||
import type { default as EmailsTable } from './Emails';
|
import type { default as EmailsTable } from './Emails';
|
||||||
import type { default as PaymentsTable } from './Payments';
|
import type { default as PaymentsTable } from './Payments';
|
||||||
|
import type { default as ComuniTable } from './Comuni';
|
||||||
import type { default as EventQueueTable } from './EventQueue';
|
import type { default as EventQueueTable } from './EventQueue';
|
||||||
import type { default as OrdiniTable } from './Ordini';
|
import type { default as OrdiniTable } from './Ordini';
|
||||||
import type { default as PrezziarioTable } from './Prezziario';
|
import type { default as PrezziarioTable } from './Prezziario';
|
||||||
|
|
@ -18,8 +19,10 @@ import type { default as RatelimiterTable } from './Ratelimiter';
|
||||||
import type { default as ChatsTable } from './Chats';
|
import type { default as ChatsTable } from './Chats';
|
||||||
import type { default as EtichetteTable } from './Etichette';
|
import type { default as EtichetteTable } from './Etichette';
|
||||||
import type { default as MessagesTable } from './Messages';
|
import type { default as MessagesTable } from './Messages';
|
||||||
|
import type { default as ProvincieTable } from './Provincie';
|
||||||
import type { default as UsersAnagraficaTable } from './UsersAnagrafica';
|
import type { default as UsersAnagraficaTable } from './UsersAnagrafica';
|
||||||
import type { default as BanlistTable } from './Banlist';
|
import type { default as BanlistTable } from './Banlist';
|
||||||
|
import type { default as NazioniTable } from './Nazioni';
|
||||||
import type { default as ImagesRefsTable } from './ImagesRefs';
|
import type { default as ImagesRefsTable } from './ImagesRefs';
|
||||||
import type { default as BannersTable } from './Banners';
|
import type { default as BannersTable } from './Banners';
|
||||||
import type { default as ServizioTable } from './Servizio';
|
import type { default as ServizioTable } from './Servizio';
|
||||||
|
|
@ -45,6 +48,8 @@ export default interface PublicSchema {
|
||||||
|
|
||||||
payments: PaymentsTable;
|
payments: PaymentsTable;
|
||||||
|
|
||||||
|
comuni: ComuniTable;
|
||||||
|
|
||||||
event_queue: EventQueueTable;
|
event_queue: EventQueueTable;
|
||||||
|
|
||||||
ordini: OrdiniTable;
|
ordini: OrdiniTable;
|
||||||
|
|
@ -59,10 +64,14 @@ export default interface PublicSchema {
|
||||||
|
|
||||||
messages: MessagesTable;
|
messages: MessagesTable;
|
||||||
|
|
||||||
|
provincie: ProvincieTable;
|
||||||
|
|
||||||
users_anagrafica: UsersAnagraficaTable;
|
users_anagrafica: UsersAnagraficaTable;
|
||||||
|
|
||||||
banlist: BanlistTable;
|
banlist: BanlistTable;
|
||||||
|
|
||||||
|
nazioni: NazioniTable;
|
||||||
|
|
||||||
images_refs: ImagesRefsTable;
|
images_refs: ImagesRefsTable;
|
||||||
|
|
||||||
banners: BannersTable;
|
banners: BannersTable;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue