Breandan Dezendorf 2 жил өмнө
parent
commit
19f86dcaa5

+ 2 - 1
dezendorf/applications/golink/cmd/main/BUILD.bazel

@@ -8,6 +8,7 @@ go_library(
     visibility = ["//visibility:private"],
     deps = [
         "//dezendorf/applications/golink/internal/core",
+        "//dezendorf/applications/golink/internal/database",
         "//dezendorf/applications/golink/internal/routes",
         "@com_github_julienschmidt_httprouter//:go_default_library"
     ]
@@ -23,4 +24,4 @@ go_image(
     name = "linkimage",
     srcs = [":main_lib"],
     visibility = ["//visibility:public"],
-)
+)

+ 1 - 0
dezendorf/applications/golink/cmd/main/main.go

@@ -8,6 +8,7 @@ import (
 
 	"github.com/julienschmidt/httprouter"
 	core "gogs.dezendorf.net/breandan/monorepo/dezendorf/applications/golink/internal/core"
+	db "gogs.dezendorf.net/breandan/monorepo/dezendorf/applications/golink/internal/database"
 	routes "gogs.dezendorf.net/breandan/monorepo/dezendorf/applications/golink/internal/routes"
 )
 

+ 0 - 16
dezendorf/applications/golink/golink_database/BUILD.bazel

@@ -1,16 +0,0 @@
-load("@com_plezentek_rules_sqlc//sqlc:def.bzl", "sqlc_package")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-sqlc_package(
-    name = "golink_database",
-    package = "database",
-    engine = "mysql",
-    queries = ["query.sql"],
-    schema = ["schema.sql"],
-)
-
-go_library(
-    name = "golink_data_library",
-    srcs = [":golink_database"],
-    importpath = "//dezendorf/applications/golink/golink_database",
-)

+ 0 - 39
dezendorf/applications/golink/golink_database/query.sql

@@ -1,39 +0,0 @@
--- name: GetAuthor :one
-SELECT * FROM authors
-WHERE id = ? LIMIT 1;
-
--- name: ListAuthors :many
-SELECT * FROM authors
-ORDER BY name;
-
--- name: CreateAuthor :execresult
-INSERT INTO authors (
-  name
-) VALUES (
-  ?
-);
-
--- name: DeleteAuthor :exec
-DELETE FROM authors
-WHERE id = ?;
-
-
-
--- name: GetLink :one
-SELECT * FROM golinks
-WHERE name = ? LIMIT 1;
-
--- name: ListLinks :many
-SELECT * FROM golinks
-ORDER BY name;
-
--- name: CreateLink :execresult
-INSERT INTO golinks (
-  name, target
-) VALUES (
-  ?, ?
-);
-
--- name: DeleteLink :exec
-DELETE FROM golinks
-WHERE id = ?;

+ 0 - 11
dezendorf/applications/golink/golink_database/schema.sql

@@ -1,11 +0,0 @@
-CREATE TABLE golinks (
-  id             BIGINT  NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  name           text    NOT NULL UNIQUE,
-  target         text    NOT NULL,
-  visit_count    BIGINT
-);
-
-CREATE TABLE authors (
-  id     BIGINT  NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  name   text    NOT NULL UNIQUE
-);

+ 11 - 0
dezendorf/applications/golink/internal/database/BUILD.bazel

@@ -0,0 +1,11 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+
+go_library(
+    name = "database",
+    srcs = ["query.sql.go",
+            "models.go",
+            "db.go"],
+    importpath = "gogs.dezendorf.net/breandan/monorepo/dezendorf/applications/golink/internal/database",
+    visibility = ["//dezendorf/applications/golink:__subpackages__"],
+    #visibility = ["//visibility:public"],
+)