Fix database initialisation (#90)
This commit is contained in:
		
							parent
							
								
									51377abf25
								
							
						
					
					
						commit
						46e55773fa
					
				@ -47,18 +47,27 @@ if [ "$1" = 'zammad-init' ]; then
 | 
				
			|||||||
  sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/    config.cache_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'\n    config.session_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'/" config/application.rb
 | 
					  sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/    config.cache_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'\n    config.session_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'/" config/application.rb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  echo "initialising / updating database..."
 | 
					  echo "initialising / updating database..."
 | 
				
			||||||
  # db mirgrate
 | 
					
 | 
				
			||||||
 | 
					  # check database
 | 
				
			||||||
  set +e
 | 
					  set +e
 | 
				
			||||||
  bundle exec rake db:migrate &> /dev/null
 | 
					  bundle exec rake db:migrate &> /dev/null
 | 
				
			||||||
  DB_CHECK="$?"
 | 
					  DB_MIGRATE="$?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if [ "${DB_MIGRATE}" == "0" ]; then
 | 
				
			||||||
 | 
					      bundle exec rails r "Setting.set('es_url', 'http://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" &> /dev/null
 | 
				
			||||||
 | 
					      DB_SETTINGS="$?"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
  set -e
 | 
					  set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [ "${DB_CHECK}" != "0" ]; then
 | 
					  # migrate database
 | 
				
			||||||
    if [ "${POSTGRESQL_DB_CREATE}" == "true" ]; then
 | 
					  if [ "${DB_MIGRATE}" != "0" -a "${POSTGRESQL_DB_CREATE}" == "true" ]; then
 | 
				
			||||||
 | 
					      echo "creating database..."
 | 
				
			||||||
      bundle exec rake db:create
 | 
					      bundle exec rake db:create
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
    bundle exec rake db:migrate
 | 
					
 | 
				
			||||||
    bundle exec rake db:seed
 | 
					  if [ "${DB_SETTINGS}" != "0" ]; then
 | 
				
			||||||
 | 
					      echo "seeding database..."
 | 
				
			||||||
 | 
					      bundle exec rake db:seed
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  echo "changing settings..."
 | 
					  echo "changing settings..."
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user