Skip to content

Commit

Permalink
Add Profile Subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Feb 14, 2024
1 parent 49d2ebb commit 3020138
Show file tree
Hide file tree
Showing 14 changed files with 1,472 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import ProfileChat from './models/ProfileChat.js';
import * as pgtypes from './schema.js';

export default class Models {
ProfileChat: ProfileChat;
Basemap: Modeler<typeof pgtypes.Basemap>;
Import: Modeler<typeof pgtypes.Import>;
Data: Modeler<typeof pgtypes.Data>;
Server: Modeler<typeof pgtypes.Server>;
Token: Modeler<typeof pgtypes.Token>;

Connection: Modeler<typeof pgtypes.Connection>;
ConnectionSink: Modeler<typeof pgtypes.ConnectionSink>;
ConnectionToken: Modeler<typeof pgtypes.ConnectionToken>;

Profile: Modeler<typeof pgtypes.Profile>;
ProfileChat: ProfileChat;
ProfileSubscription: Modeler<typeof pgtypes.ProfileSubscription>;
ProfileOverlay: Modeler<typeof pgtypes.ProfileOverlay>;

Iconset: Modeler<typeof pgtypes.Iconset>;
Icon: Modeler<typeof pgtypes.Icon>;
Server: Modeler<typeof pgtypes.Server>;
Token: Modeler<typeof pgtypes.Token>;

Layer: Modeler<typeof pgtypes.Layer>;
LayerAlert: Modeler<typeof pgtypes.LayerAlert>;

Expand All @@ -26,6 +31,7 @@ export default class Models {
this.Server = new Modeler(pg, pgtypes.Server);
this.Profile = new Modeler(pg, pgtypes.Profile);
this.ProfileOverlay = new Modeler(pg, pgtypes.ProfileOverlay);
this.ProfileSubscription = new Modeler(pg, pgtypes.ProfileSubscription);
this.Basemap = new Modeler(pg, pgtypes.Basemap);
this.Import = new Modeler(pg, pgtypes.Import);
this.Connection = new Modeler(pg, pgtypes.Connection);
Expand Down
7 changes: 7 additions & 0 deletions api/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export const Profile = pgTable('profile', {
tak_loc: geometry('tak_loc', { srid: 4326, type: GeometryType.Point })
});

export const ProfileSubscription = pgTable('profile_subscriptions', {
username: text('username').primaryKey(),
created: timestamp('created', { withTimezone: true }).notNull().default(sql`Now()`),
updated: timestamp('updated', { withTimezone: true }).notNull().default(sql`Now()`),
mission: text('mission').notNull()
});

export const ProfileChat = pgTable('profile_chats', {
username: text('username').primaryKey(),
chatroom: text('chatroom').notNull(),
Expand Down
6 changes: 6 additions & 0 deletions api/migrations/0010_gorgeous_lifeguard.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS "profile_subscriptions" (
"username" text PRIMARY KEY NOT NULL,
"created" timestamp with time zone DEFAULT Now() NOT NULL,
"updated" timestamp with time zone DEFAULT Now() NOT NULL,
"mission" text NOT NULL
);
Loading

0 comments on commit 3020138

Please sign in to comment.