Update
This commit is contained in:
28
Server/db/connection_template.yml
Normal file
28
Server/db/connection_template.yml
Normal 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
42
Server/db/init_db.jl
Normal 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
|
0
Server/db/migrations/.gitkeep
Normal file
0
Server/db/migrations/.gitkeep
Normal file
27
Server/db/migrations/2019052410085235_create_table_users.jl
Normal file
27
Server/db/migrations/2019052410085235_create_table_users.jl
Normal 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
|
20
Server/db/migrations/2021061519495560_create_table_roles.jl
Normal file
20
Server/db/migrations/2021061519495560_create_table_roles.jl
Normal 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
|
@@ -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
|
@@ -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
|
@@ -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
0
Server/db/seeds/.gitkeep
Normal file
Reference in New Issue
Block a user