-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store created and modified time separately on database for book…
…marks (#896) * sqlite migrate script * create time just when bookmark added and modified update if change happen * show added and modified time in footer instead of header * add bun.lockb that missing * add migrate for postgres * add pg support of created time * change modifed to modifed_at and create to created_at in sqlite * change modifed to modifed_at and create to created_at in postgre * add created_at to mariadb * fix migration file names * better variable name and more clear code for add modified time if created and modified is not in same day * add unittest * add unittest to sure filters work as expected * index for created_at and modified_at * build new styles.css * update swagger documents * make styles * change Created and Modified to CreatedAt and ModifiedAt * fix missing Modified * fix typo * missing Modified * fix typo * make swagger * run tests parallel Co-authored-by: Felipe Martin <[email protected]> * remove t.Parallel() * remove dayjs dependency and combine two function * better unittest name * fix typo * diffrnt footer style for login and content page * use class instead of id * back parallel * change duplicate url * remvoe run Parallel * make styles --------- Co-authored-by: Felipe Martin <[email protected]>
- Loading branch information
1 parent
a3d4a68
commit 4a5564d
Showing
26 changed files
with
284 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
internal/database/migrations/mysql/0005_rename_to_created_at.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE bookmark RENAME COLUMN modified to created_at; |
2 changes: 2 additions & 0 deletions
2
internal/database/migrations/mysql/0006_change_created_at_settings.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE bookmark | ||
MODIFY created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; |
2 changes: 2 additions & 0 deletions
2
internal/database/migrations/mysql/0007_add_modified_at.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE bookmark | ||
ADD COLUMN modified_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; |
3 changes: 3 additions & 0 deletions
3
internal/database/migrations/mysql/0008_set_modified_at_equal_created_at.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
UPDATE bookmark | ||
SET modified_at = COALESCE(created_at, CURRENT_TIMESTAMP) | ||
WHERE created_at IS NOT NULL; |
1 change: 1 addition & 0 deletions
1
internal/database/migrations/mysql/0009_index_for_created_at.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX idx_created_at ON bookmark (created_at); |
1 change: 1 addition & 0 deletions
1
internal/database/migrations/mysql/0010_index_for_modified_at.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX idx_modified_at ON bookmark (modified_at); |
16 changes: 16 additions & 0 deletions
16
internal/database/migrations/postgres/0002_created_time.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- Rename "modified" column to "created_at" | ||
ALTER TABLE bookmark | ||
RENAME COLUMN modified to created_at; | ||
|
||
-- Add the "modified_at" column to the bookmark table | ||
ALTER TABLE bookmark | ||
ADD COLUMN modified_at TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
|
||
-- Update the "modified_at" column with the value from the "created_at" column if it is not null | ||
UPDATE bookmark | ||
SET modified_at = COALESCE(created_at, CURRENT_TIMESTAMP) | ||
WHERE created_at IS NOT NULL; | ||
|
||
-- Index for "created_at" "modified_at"" | ||
CREATE INDEX idx_created_at ON bookmark(created_at); | ||
CREATE INDEX idx_modified_at ON bookmark(modified_at); |
12 changes: 12 additions & 0 deletions
12
internal/database/migrations/sqlite/0004_created_time.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ALTER TABLE bookmark | ||
RENAME COLUMN modified to created_at; | ||
|
||
ALTER TABLE bookmark | ||
ADD COLUMN modified_at TEXT NULL; | ||
|
||
UPDATE bookmark | ||
SET modified_at = bookmark.created_at | ||
WHERE created_at IS NOT NULL; | ||
|
||
CREATE INDEX idx_created_at ON bookmark(created_at); | ||
CREATE INDEX idx_modified_at ON bookmark(modified_at); |
Oops, something went wrong.