aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorSamuel Johnson <[email protected]>2025-12-11 15:09:30 -0500
committerSamuel Johnson <[email protected]>2025-12-11 15:09:30 -0500
commit61ba5dcc29a16bb3727209a76ee75fffff037dee (patch)
tree4505ebfe8aadeae024e2f36fb948f9e79841a0f1 /internal
parent154e2a5417bca37cd7474f4e16fd8901844e473f (diff)
Add commenting system
Diffstat (limited to 'internal')
-rw-r--r--internal/dbmigrations.go8
-rw-r--r--internal/models/comment.go12
2 files changed, 20 insertions, 0 deletions
diff --git a/internal/dbmigrations.go b/internal/dbmigrations.go
index fcbaaaf..41180c7 100644
--- a/internal/dbmigrations.go
+++ b/internal/dbmigrations.go
@@ -56,4 +56,12 @@ func Migrate(db *sql.DB, webmaster string, passOne string, passTwo string) {
fmt.Fprintf(os.Stderr, "Unable to create cookies table: %v\n", err)
}
}
+
+ _, table_check = db.Query("SELECT * FROM comments;")
+ if table_check != nil {
+ _, err := db.Exec("CREATE TABLE comments (id SERIAL PRIMARY KEY, verified BOOLEAN NOT NULL, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, name TEXT NOT NULL, post_id INTEGER REFERENCES posts(id), content TEXT NOT NULL);")
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Unable to create comments table: %v\n", err)
+ }
+ }
}
diff --git a/internal/models/comment.go b/internal/models/comment.go
new file mode 100644
index 0000000..df27ca3
--- /dev/null
+++ b/internal/models/comment.go
@@ -0,0 +1,12 @@
+package models
+
+import "time"
+
+type Comment struct {
+ Id int
+ IsVerified bool
+ Time time.Time
+ FormattedTime string
+ Name string
+ Content string
+}