Database: DB progress & .sql files for tables

master
E. Almqvist 3 years ago
parent a8f5e9d548
commit 98b16a9008
  1. 4
      src/database.rb
  2. 7
      src/sql/tables/Role.sql
  3. 11
      src/sql/tables/User.sql

@ -1,7 +1,5 @@
DEFAULT_DB_PATH = "db/main.db"
require_relative "db_models.rb"
class Table
attr_reader :name
attr_accessor :db
@ -12,6 +10,8 @@ class Table
end
end
require_relative "db_models.rb"
class Database # Database class
attr_reader :name, :path
attr_accessor :tables

@ -0,0 +1,7 @@
CREATE TABLE "Role" (
"id" INTEGER NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"color" INTEGER NOT NULL DEFAULT 16777215,
"flags" INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY("id" AUTOINCREMENT)
);

@ -0,0 +1,11 @@
CREATE TABLE "User" (
"id" INTEGER NOT NULL UNIQUE,
"email" TEXT NOT NULL UNIQUE,
"pw_hash" TEXT NOT NULL UNIQUE,
"name" TEXT NOT NULL DEFAULT 'Unknown',
"bio_text" TEXT,
"balance" REAL NOT NULL DEFAULT 0,
"avatar_url" TEXT NOT NULL DEFAULT '/avatars/default.png',
"reputation" INTEGER NOT NULL DEFAULT 100,
PRIMARY KEY("id" AUTOINCREMENT)
);
Loading…
Cancel
Save