This commit is contained in:
a-ill
2023-06-14 21:41:54 +03:00
parent 4d034eba7d
commit 9e8ee05bb6
128 changed files with 12242 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
env: ENV["GENIE_ENV"]
dev:
adapter: PostgreSQL
database: namegoeshere
host: localhost
username: postgres
password: passwordgoeshere
port: 5432
config:
prod:
adapter: PostgreSQL
database: namegoeshere
host: localhost
username: postgres
password: passwordgoeshere
port: 5432
config:
test:
adapter: PostgreSQL
database: namegoeshere
host: localhost
username: postgres
password: passwordgoeshere
port: 5432
config:

42
Server/db/init_db.jl Normal file
View File

@@ -0,0 +1,42 @@
cd(@__DIR__)
cd("..")
@info pwd()
using Pkg
Pkg.activate(".")
Pkg.instantiate()
using SearchLight, SearchLightPostgreSQL
include("../lib/DatabaseSupport.jl")
using .DatabaseSupport
import SearchLight.query
#Connect to the database
SearchLight.Configuration.load() |> SearchLight.connect
# Initialize the database for Julia
#SearchLight.Migrations.create_migrations_table()
#DEBUG remove all tables
#SearchLight.Migration.all_down!!()
#DEBUG
#Load all tables and print status
#SearchLight.Migration.all_up!!(context=Server)
#SearchLight.Migration.status()
cd(@__DIR__)
p = "migrations/"
files = readdir(p)
files = files[map(x -> x[end-1:end].=="jl", files)]
inds = map(x -> parse(Int64,split(x,"_")[1]), files)
inds_sorted = sortperm(inds)
files = files[inds_sorted]
for f in files
try
m = include(joinpath(p,f))
m.up()
catch
end
end

View File

View File

@@ -0,0 +1,27 @@
module CreateTableUsers
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
function up()
create_table(:users) do
[
primary_key()
column(:email, :string)
column(:password, :string, limit = 100)
column(:name, :string)
column(:profile_picture, :int)
column(:country, :int)
column(:newsletter, :bool)
column(:notifications, :int)
column(:confirmation_code, :string)
]
end
add_index(:users, :email)
end
function down()
drop_table(:users)
end
end

View File

@@ -0,0 +1,20 @@
module CreateTableRoles
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
function up()
create_table(:roles) do
[
primary_key()
column(:name, :string, limit = 100)
]
end
add_index(:roles, :name)
end
function down()
drop_table(:roles)
end
end

View File

@@ -0,0 +1,20 @@
module CreateTablePermissions
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
function up()
create_table(:permissions) do
[
primary_key()
column(:name, :string, limit = 100)
]
end
add_index(:permissions, :name)
end
function down()
drop_table(:permissions)
end
end

View File

@@ -0,0 +1,22 @@
module CreateTableRolesUsers
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
function up()
create_table(:rolesusers) do
[
primary_key()
column(:roles_id, :int)
column(:users_id, :int)
]
end
add_index(:rolesusers, :roles_id)
add_index(:rolesusers, :users_id)
end
function down()
drop_table(:rolesusers)
end
end

View File

@@ -0,0 +1,21 @@
module CreateTablePermissionsRoles
import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table
function up()
create_table(:permissionsroles) do
[
primary_key()
column(:permissions_id, :int)
column(:roles_id, :int)
]
end
add_index(:permissionsroles, :permissions_id)
end
function down()
drop_table(:permissionsroles)
end
end

0
Server/db/seeds/.gitkeep Normal file
View File