Skip to content

Commit 82cbe53

Browse files
prepare to use Temporal
1 parent 4be886b commit 82cbe53

File tree

6 files changed

+1023
-5787
lines changed

6 files changed

+1023
-5787
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# First time setup
22

33
Install dependances
4+
45
```sh
56
pnpm i
67
```
8+
79
Create migrations
810

911
```sh
@@ -12,7 +14,6 @@ pnpm run db:migrate
1214
pnpm run db:seed
1315
```
1416

15-
1617
Create and apply new migrations
1718

1819
```sh
@@ -24,4 +25,29 @@ Apply new migrations after a git pull
2425

2526
```sh
2627
pnpm db:migrate
27-
```
28+
```
29+
30+
# date conventions based on js datetime
31+
32+
# Schema data storeage info
33+
34+
##Everyday
35+
no pattern needed, only seperation if for example every 2 days then seperation count of 1
36+
37+
##Weekly Recurrence
38+
dayOfWeek, eg 1 would be every monday assuming monday is start of week
39+
bi weekly on tuesday would be dayOfWeek:2, separationCount :1
40+
41+
##monthly recurrance
42+
for every 2nd week, we store weekOfMonth:2
43+
for one day of the month just dayOfMonth, eg 25 for 25th day
44+
45+
11th day of the first month in each quarter
46+
dayOfMonth:11
47+
separationCount:2
48+
49+
# Yearly Recurrence
50+
51+
lets day every 6th june
52+
monthOfYear: 6
53+
dayOfMonth: 6
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CREATE TABLE `event` (
2+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3+
`name` text NOT NULL,
4+
`start_time` integer NOT NULL,
5+
`end_time` integer NOT NULL,
6+
`created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
7+
`updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
8+
`deleted_at` integer,
9+
`is_recurring` integer DEFAULT false NOT NULL
10+
);
11+
--> statement-breakpoint
12+
CREATE TABLE `recurring_pattern` (
13+
`event_id` integer PRIMARY KEY NOT NULL,
14+
`separation_count` integer DEFAULT 0 NOT NULL,
15+
`max_num_of_occurrences` integer,
16+
`end_date` integer,
17+
`day_of_week` integer,
18+
`week_of_month` integer,
19+
`day_of_month` integer,
20+
`month_of_year` integer,
21+
`recurring_type_id` integer,
22+
FOREIGN KEY (`event_id`) REFERENCES `event`(`id`) ON UPDATE no action ON DELETE cascade,
23+
FOREIGN KEY (`recurring_type_id`) REFERENCES `recurring_type`(`id`) ON UPDATE no action ON DELETE no action
24+
);
25+
--> statement-breakpoint
26+
CREATE TABLE `recurring_type` (
27+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
28+
`type` text NOT NULL
29+
);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"test:watch": "vitest watch"
1616
},
1717
"dependencies": {
18-
"better-sqlite3": "^9.2.2"
18+
"better-sqlite3": "^9.2.2",
19+
"temporal-polyfill": "^0.2.0"
1920
},
2021
"devDependencies": {
2122
"dotenv": "^16.3.1",

0 commit comments

Comments
 (0)