1+ #! /usr/bin/env tarantool
2+
3+ -- Add Taranrocks pathes. https://github.com/rtsisyk/taranrocks/blob/master/README.md
4+ local home = os.getenv (" HOME" )
5+ package.path = [[ /usr/local/share/tarantool/lua/?/init.lua;]] .. package.path
6+ package.path = [[ /usr/local/share/tarantool/lua/?.lua;]] .. package.path
7+ package.path = home .. [[ /.tarantool/share/tarantool/lua/?/init.lua;]] .. package.path
8+ package.path = home .. [[ /.tarantool/share/tarantool/lua/?.lua;]] .. package.path
9+ package.cpath = [[ /usr/local/lib/tarantool/lua/?.so;]] .. package.cpath
10+ package.cpath = home .. [[ /.tarantool/lib/tarantool/lua/?.so;]] .. package.cpath
11+
12+ local log = require (' log' )
13+
14+ box .cfg
15+ {
16+ pid_file = nil ,
17+ background = false ,
18+ log_level = 5
19+ }
20+
21+ local function init ()
22+ box .schema .user .create (' operator' , {password = ' 123123' , if_not_exists = true })
23+ box .schema .user .grant (' operator' , ' read,write,execute' , ' universe' , nil , { if_not_exists = true })
24+
25+ box .schema .user .create (' replicator' , {password = ' 234234' , if_not_exists = true })
26+ box .schema .user .grant (' replicator' ,' execute' ,' role' ,' replication' , { if_not_exists = true })
27+
28+ some_space = box .schema .space .create (' some_space' , { field_count = 5 , format = {
29+ [1 ] = {[" name" ] = " id" },
30+ [2 ] = {[" name" ] = " text" },
31+ [3 ] = {[" name" ] = " int" }
32+ }})
33+ log .info (some_space .name .. " space was created." )
34+
35+ some_space :create_index (' primary' , {
36+ if_not_exists = true ,
37+ type = ' HASH' ,
38+ unique = true ,
39+ parts = {1 , ' INT' }
40+ })
41+
42+ some_space :create_index (' some_secondary_index' , {
43+ if_not_exists = true ,
44+ type = ' TREE' ,
45+ unique = false ,
46+ parts = {3 , ' INT' }
47+ })
48+ end
49+
50+ box .once (' init' , init )
0 commit comments