2016년 5월 30일 월요일

Glassfish Installation in Debian

Before installation of the glassfish, make sure of java version. the Glassfish V3 need the JDK 1.7.0 and the Glassfish V4 need the JDK 1.8.0.

scwook@debian:~/Download# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

If you need to install the new Java, Please refer to following post



Glassfish V3 Installation

Glassfish V3 can be downloaded from the Oracle web page. Download the Linux/Unix/Mac Installer.


Run the file as superuser.

root@debian:/Downloads# bash ogs-3.1.2.2-unix.sh

When installation menu show up, click next.


Select the Typical Installation and click next.


Change the Installation Directory to /opt/glassfish3 and click next.


Click next.


Click next to start installation.


Set the administrator password and leave the default settings. click next.


Installation is completed. Click exit.


In order to test, try poining your browser to localhost or server ip address.

http://localhost:4848 or http://[Server IP Address]:4848

Glassfish V4 Installation

Download the Java EE 7 Full Platform form the glassfish wep site.



Extract the file and run the glassfish demon.

root@debian:~# unzip glassfish-4.1.1.zip -d /opt/
root@debian:~# cd /opt/glassfish4/bin/
root@debian:/opt/glassfish4/bin# ./asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

In order to test, try poining your browser to localhost or server ip address.

http://localhost:4848 or http://[Server IP Address]:4848

If need, the admin password can be modified by change-admin-password command.

root@debian:/opt/glassfish4/bin# ./asadmin change-admin-password

Enter admin user name [default: admin]>admin

Enter the admin password> [Just remain empty]
Enter the new admin password> [New Password] 
Enter the new admin password again> [New Password]

2016년 5월 25일 수요일

Java Installation in the Debain Jessie

Using update-alternatives command, you can add new Java version in the Jessie. First, check current Java version.

scwook@debian:~$ java -version
openjdk version "1.8.0_72-internal"
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)

Download new Java version form the web page and uncompressing.


http://www.oracle.com/technetwork/java/javase/downloads/index.html


root@debian:~/Download# tar xvf jdk-8u91-linux-x64.tar.gz -C /opt/

Register new Java with --install option

root@debian:~/Download# update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_91/bin/java 1
root@debian:~/Download# update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_91/bin/javac 1

Change Java version with --config option

root@debian:~/Download# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      auto mode
  1            /opt/jdk1.8.0_91/bin/java                        1         manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode
Press enter to keep the current choice[*], or type selection number: 1

Now you have new Java.

root@debian:~/Download# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

2016년 5월 24일 화요일

Raspberry Pi - PIR Motion Sensor test

PIR motion sensor used to detect whether a object which emits infrared radiation has moved in or out the sensor range. If the sensor detect a moving object, it make output signal. More infromation about the sensor can be found in the following web page. In order to test, the wiringPi must be installed.

http://www.dfrobot.com/wiki/index.php/PIR_Motion_Sensor_V1.0_SKU:SEN0171

The test circuit is shown as in figure.

Component

  • Raspberry Pi 2 Model B
  • PIR Motion Sensor (DFROBOT SEN0171)


In order to test, make a simple code which is pirTest.c

#include <stdio.h>
#include <wiringPi.h>

#define PIR 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(PIR, INPUT);

  int input = 0;

  for(;;)
  {
    if(digitalRead(PIR))
      printf("Motion Detected!\n");

    delay(100);
  }

  return 0;
}

Compile and run the program.

pi@raspberrypi ~$ gcc -o pirTest pirTest.c -lwiringPi
pi@raspberrypi ~$ sudo ./pirTest

When a moving object is detected, "Motion Detected" message will be printed.

2016년 5월 20일 금요일

Raspberry Pi - wiringPi Installation

One method to use GPIO Port of raspberry pi is using wiringPi. Basic information and guide is in wiringPi web site.

http://wiringpi.com/

wiringPi can be downloaded form git. So git must be installed first.

pi@raspberrypi ~$ sudo su -
root@raspberrypi:~# aptitude install git
root@raspberrypi:~# exit
pi@raspberrypi ~$ git clone git://git.drogon.net/wiringPi
Cloning into 'wiringPi'...
remote: Counting objects: 657, done.
remote: Compressing objects: 100% (599/599), done.
remote: Total 657 (delta 476), reused 95 (delta 58)
Receiving objects: 100% (657/657), 247.61 KiB | 94 KiB/s, done.
Resolving deltas: 100% (476/476), done.

Build from source code.

pi@raspberrypi ~$ cd wiringPi
pi@raspberrypi ~/wiringPi$ ./build

Pin Layout can be checked by gpio readall command.



Rasbperry Pi - wiringPi 설치

Raspberry Pi에서 GPIO Port를 사용할 수 있는 방법 중 하나는 wiringPi를 이용하는 것이다. wiringPi에 대한 기본적인 사용 방법 및 wiringPi 홈페이지에서 확인할 수 있다.

http://wiringpi.com/

wiringPi는 소스 코드는 git에서 받을 수 있으며, 코드를 빌드 하는것으로 설치는 끝난다. git이 설치되어 있지 않다면 git을 먼저 설치한다.

pi@raspberrypi ~$ sudo su -
root@raspberrypi:~# aptitude install git
root@raspberrypi:~# exit
pi@raspberrypi ~$ git clone git://git.drogon.net/wiringPi
Cloning into 'wiringPi'...
remote: Counting objects: 657, done.
remote: Compressing objects: 100% (599/599), done.
remote: Total 657 (delta 476), reused 95 (delta 58)
Receiving objects: 100% (657/657), 247.61 KiB | 94 KiB/s, done.
Resolving deltas: 100% (476/476), done.

받은 코드를 빌드한다.

pi@raspberrypi ~$ cd wiringPi
pi@raspberrypi ~/wiringPi$ ./build

Pin Layout은 gpio readall 명령으로 확인 할 수 있다. wiringPi는 자체 Pin Map을 사용하는데 wPi로 표시된 부분은 wiringPi에서 사용하는 GPIO 핀 번호이다.

pi@raspberrypi ~$ gpio readall

다음은 Raspberry Pi Model B+ 기준의 Pin Map이다.








2016년 5월 19일 목요일

Raspberry Pi - PIR Motion Sensor 테스트

PIR Motion Sensor는 적외선으로 움직임을 감지하는 센서로 일정한 범위 내에 적외선을 방출하는 물체가 움직일 경우 이를 감지하여 출력 신호로 내보낸다. 센서에 대한 자세한 사양은 다음 웹페이지에서 확인할 수 있으며 테스트를 위해서는 wiringPi가 설치되어 있어야 한다.

http://www.dfrobot.com/wiki/index.php/PIR_Motion_Sensor_V1.0_SKU:SEN0171

테스트 회로는 그림과 같이 PIR Motion Sensor에 5V의 입력 전압을 연결하고 움직임이 감지되었을 때 나오는 출력 전압을 GPIO의 1번에 연결하였다.

회로 및 구성

  • Raspberry Pi 2 Model B
  • PIR Motion Sensor (입력 전압: 3.3 ~ 5V, 출력 전압: High 3V, Low 0V)




테스트를 위해 pir.c 코드를 다음과 같이 작성한다.

#include <stdio.h>
#include <wiringPi.h>

#define PIR 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(PIR, INPUT);

  int input = 0;

  for(;;)
  {
    if(digitalRead(PIR))
      printf("Motion Detected!\n");

    delay(100);
  }

  return 0;
}

코드를 컴파일 하고 실행 시킨다.

pi@raspberrypi ~$ gcc -o pir pir.c -lwiringPi
pi@raspberrypi ~$ sudo ./pir

Raspberry Pi - GPIO input test with Button

Let's turn on LED when a button is pushed. Before the test, wiringPi must be installed.

The test circuit is shown as in figure. one leg of button is connect to 5V output pin and another leg is connect to #1 pin of GPIO and 10k pull-down resistor is used to prevent floating state.  In order to monitor button state, LED is used.

※ Be careful!!. If LED is connected to reverse polarity, it will be broken. Long leg is positive(+) and short leg is negative(-).

Component
  • Raspberry Pi 2 Model B
  • Push Button
  • LED(Operating Voltage: 1.8V ~ 2.3V)
  • Resistor 250Ω, 10k 


In order to test, make a simple code which is buttonTest.c

#include <wiringPi.h>

#define LED 4
#define BUTTON 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);

  digitalWrite(LED, 0);
  int input = 0;

  for(;;)
  {
    if(digitalRead(BUTTON))
      digitalWrite(LED, 1);
    else
      digitalWrite(LED, 0); 

    delay(100);
  }

  return 0;
}

Compile and run the program.

pi@raspberrypi ~$ gcc -o buttonTest buttonTest.c -lwiringPi
pi@raspberrypi ~$ sudo ./buttonTest

When the button is pushed, LED will be turned on.

2016년 5월 18일 수요일

Raspberry Pi - Button을 이용한 GPIO 입력 테스트

Raspberry Pi의 GPIO를 이용하여 버튼이 눌러졌을 때 LED를 켜는 테스트를 해 보자. 테스트를 위해서는 기본적으로 wiringPi가 설치되어 있어야 한다.

테스트 회로는 그림과 같이 Push Button을 눌렀을 때 1번 Pin에 High가 인가 되도록 5V를 연결하였으며 10kΩ의 Pull-down 저항을 연결하였다. LED는 버튼이 눌러진 것을 확인하기 위해 연결하였다.

※ LED의 극성을 반대로 연결하면 LED가 고장 나므로 주의해서 연결한다. 길이가 짧은 쪽이(-), 긴 쪽이 (+)이다. 

회로 및 구성

  • Raspberry Pi 2 Model B
  • Push Button
  • LED (동작 전압: 1.8V ~ 2.3V)
  • 저항 250Ω, 10kΩ




테스트를 위해 buttonTest.c 코드를 다음과 같이 작성한다.

#include <wiringPi.h>

#define LED 4
#define BUTTON 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);

  digitalWrite(LED, 0);
  int input = 0;

  for(;;)
  {
    if(digitalRead(BUTTON))
      digitalWrite(LED, 1);
    else
      digitalWrite(LED, 0); 

    delay(100);
  }

  return 0;
}

코드를 컴파일 하고 실행 시킨다.

pi@raspberrypi ~$ gcc -o buttonTest buttonTest.c -lwiringPi
pi@raspberrypi ~$ sudo ./buttonTest


버튼을 누르면 LED에 불이 들어오는 것을 확인할 수 있다.

Raspberry Pi - GPIO output test with LED

Let's turn on LED using a Raspberry Pi GPIO port. Before the test, wiringPi must be installed. 

※ Be careful!!. If LED is connected to reverse polarity, it will be broken. Long leg is positive(+) and short leg is negative(-).

Component
  • Raspberry Pi 2 Model B
  • LED (Operating Voltage: 1.8V ~ 2.3V)
  • Resistor 250Ω





In order to test, make a simple code which is ledtest.c

#include <wiringPi.h>

#define LED1 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(LED1, OUTPUT);
  digitalWrite(LED1, 1);

  return 0;
}

Complie and run the program.

pi@raspberrypi ~$ gcc -o ledtest ledtest.c -lwiringPi
pi@raspberrypi ~$ sudo ./ledtest


After run the program, LED will be turned on.

2016년 5월 17일 화요일

Raspberry Pi - LED를 이용한 GPIO 출력 테스트

Raspberry Pi의 GPIO를 이용하여 간단한 LED를 켜는 테스트를 해 보자. 테스트에 앞서 wiringPi가 설치되어 있지 않다면 wiringPi를 먼저 설치하도록 한다.

테스트 회로는 다음과 같이 발광 다이오드의 (+)를 1번에 연결하고 (-)를 GND에 연결하였으며 (+)와 1번 사이에 250Ω의 저항을 연결하였다.

※ LED의 극성을 반대로 연결하면 LED가 고장 나므로 주의해서 연결한다. 길이가 짧은 쪽이(-), 긴 쪽이 (+)이다. 

회로 및 구성

  • Raspberry Pi 2 Model B
  • LED (동작 전압: 1.8V ~ 2.3V)
  • 저항 250Ω




테스트를 위해 다음과 같이 코드를 작성한다.
#include <wiringPi.h>

#define LED1 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(LED1, OUTPUT);
  digitalWrite(LED1, 1);

  return 0;
}

코드를 컴파일 하고 실행 시킨다.

pi@raspberrypi ~$ gcc -o ledtest ledtest.c -lwiringPi
pi@raspberrypi ~$ sudo ./ledtest

프로그램이 실행되면 LED에 불이 들어오는 것을 확인할 수 있다.

2016년 5월 16일 월요일

Debian에서 Glassfish 설치


Glassfish를 설치하기 전 Java 버전을 먼저 확인한다. Glassfish V3는 JDK 1.7.0, Glassfish V4는 JDK 1.8.0 이상 설치되어 있어야 한다.


scwook@debian:~/Download# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

JAVA 설치 방법은 다음 Post를 참고한다.

http://scwook.blogspot.kr/2016/05/debian-jessie-java.html


Glassfish V3 설치

Glassfish V3은 Oracle 홈페이지에서 받을 수 있다. 다운로드 페이지에서 Linux/Unix/Mac Installer 파일을 다운 받는다.


다운받은 파일을 관리자 권한으로 실행한다.

root@debian:/Downloads# bash ogs-3.1.2.2-unix.sh

설치 화면이 나타나면 Next를 누른다.



Typical Installation을 선택한 후 Next를 누른다.



설치 위치를 /opt/glassfish3로 변경한 후 Next를 누른다.



Next를 누른다.



Install을 누르면 설치가 시작된다.



설치가 완료되면 설정 메뉴가 나타난다. 기본 설정으로 두고 Username과 Password를 입력한 후 Next를 누른다.



설치가 완료되면 Exit를 누른다.


테스트를 위해 다음 주소록 접속한다.

http://localhost:4848 또는 http://[Server IP Address]:4848

Glassfish V4 설치

Glassfish 사이트에 접속하여 Java EE 7 Full Platform 파일을 다운 받는다.




다운 받은 파일의 압축을 풀고 daemon을 실행한다.

root@debian:~# unzip glassfish-4.1.1.zip -d /opt/
root@debian:~# cd /opt/glassfish4/bin/
root@debian:/opt/glassfish4/bin# ./asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

다음 주소로 접속한다.


필요한 경우 change-admin-password 명령으로 관리자 암호를 설정한다.

root@debian:/opt/glassfish4/bin# ./asadmin change-admin-password

Enter admin user name [default: admin]>admin

Enter the admin password> [아무것도 입력하지 않음]
Enter the new admin password> [새로 설정할 암호] 
Enter the new admin password again> [새로 설정할 암호]

자동 실행
create-service 명령을 사용하면 /etc/init.d/ 폴더에 GlassFish_domain1 실행 스크립트가 생성된다.

root@debian:/opt/glassfish4/bin# ./asadmin create-service

update-rc 명령으로 GlassFish_domain1을 등록한다.

root@debian:/etc/init.d# update-rc GlassFish_domain1 default


2016년 5월 15일 일요일

Olog Mysql Database Schema

This is a schema for MySQL Olog database. Just copy and make a file such as "olog.sql". following command can load the file.

mysql> source olog.sql;

-- MySQL dump 10.13  Distrib 5.5.49, for debian-linux-gnu (x86_64)
--
-- Host: localhost    Database: olog
-- ------------------------------------------------------
-- Server version 5.5.49-0+deb7u1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `olog`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `olog` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `olog`;

--
-- Table structure for table `attributes`
--

DROP TABLE IF EXISTS `attributes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `attributes` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `property_id` int(11) unsigned NOT NULL,
  `name` varchar(200) NOT NULL,
  `state` enum('Active','Inactive') NOT NULL DEFAULT 'Active',
  PRIMARY KEY (`id`),
  KEY `attributes_property_id_fk` (`property_id`),
  CONSTRAINT `attributes_property_id_fk` FOREIGN KEY (`property_id`) REFERENCES `properties` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `attributes`
--

LOCK TABLES `attributes` WRITE;
/*!40000 ALTER TABLE `attributes` DISABLE KEYS */;
/*!40000 ALTER TABLE `attributes` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `entries`
--
This is a schema of MySQL for 


DROP TABLE IF EXISTS `entries`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `entries` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `entries`
--

LOCK TABLES `entries` WRITE;
/*!40000 ALTER TABLE `entries` DISABLE KEYS */;
/*!40000 ALTER TABLE `entries` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `logbooks`
--

DROP TABLE IF EXISTS `logbooks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logbooks` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `is_tag` int(1) unsigned NOT NULL DEFAULT '0',
  `owner` varchar(45) DEFAULT NULL,
  `state` enum('Active','Inactive') NOT NULL DEFAULT 'Active',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `logbooks`
--

LOCK TABLES `logbooks` WRITE;
/*!40000 ALTER TABLE `logbooks` DISABLE KEYS */;
INSERT INTO `logbooks` VALUES (1,'Operations',0,NULL,'Active'),(2,'Electronics Maintenance',0,NULL,'Active'),(3,'Mechanical Technicians',0,NULL,'Active'),(4,'LOTO',0,NULL,'Active'),(5,'Inverpower Power Supplies',1,NULL,'Active'),(6,'RF Area',1,NULL,'Active'),(7,'Kicker',1,NULL,'Active'),(8,'Bumps',1,NULL,'Active'),(9,'Septums',1,NULL,'Active'),(10,'Large Power Supplies',1,NULL,'Active'),(11,'Timing Systems',1,NULL,'Active');
/*!40000 ALTER TABLE `logbooks` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `logs`
--

DROP TABLE IF EXISTS `logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logs` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `modified` datetime NOT NULL,
  `source` varchar(80) NOT NULL DEFAULT '',
  `owner` varchar(32) NOT NULL,
  `description` mediumtext NOT NULL,
  `md5entry` varchar(32) NOT NULL DEFAULT '',
  `state` enum('Active','Inactive') NOT NULL DEFAULT 'Active',
  `level` enum('Info','Problem','Request','Suggestion','Urgent') NOT NULL DEFAULT 'Info',
  `entry_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `entry_id_fk` (`entry_id`),
  CONSTRAINT `entry_id_fk` FOREIGN KEY (`entry_id`) REFERENCES `entries` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `logs`
--

LOCK TABLES `logs` WRITE;
/*!40000 ALTER TABLE `logs` DISABLE KEYS */;
/*!40000 ALTER TABLE `logs` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `logs_attributes`
--

DROP TABLE IF EXISTS `logs_attributes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logs_attributes` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `log_id` int(11) unsigned NOT NULL,
  `attribute_id` int(11) unsigned NOT NULL,
  `value` varchar(200) NOT NULL,
  `grouping_num` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `logs_attributes_attribute_id_fk` (`attribute_id`),
  KEY `logs_attributes_log_id_fk` (`log_id`),
  CONSTRAINT `logs_attributes_attribute_id_fk` FOREIGN KEY (`attribute_id`) REFERENCES `attributes` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `logs_attributes_log_id_fk` FOREIGN KEY (`log_id`) REFERENCES `logs` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=179 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `logs_attributes`
--

LOCK TABLES `logs_attributes` WRITE;
/*!40000 ALTER TABLE `logs_attributes` DISABLE KEYS */;
/*!40000 ALTER TABLE `logs_attributes` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `logs_logbooks`
--

DROP TABLE IF EXISTS `logs_logbooks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logs_logbooks` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `log_id` int(11) unsigned NOT NULL,
  `logbook_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `log_id_fk` (`log_id`),
  KEY `logbook_id_fk` (`logbook_id`) USING BTREE,
  CONSTRAINT `log_id_fk` FOREIGN KEY (`log_id`) REFERENCES `logs` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `logbook_id_fk` FOREIGN KEY (`logbook_id`) REFERENCES `logbooks` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `logs_logbooks`
--

LOCK TABLES `logs_logbooks` WRITE;
/*!40000 ALTER TABLE `logs_logbooks` DISABLE KEYS */;
/*!40000 ALTER TABLE `logs_logbooks` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `properties`
--

DROP TABLE IF EXISTS `properties`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `properties` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `state` enum('Active','Inactive') NOT NULL DEFAULT 'Active',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `properties`
--

LOCK TABLES `properties` WRITE;
/*!40000 ALTER TABLE `properties` DISABLE KEYS */;
/*!40000 ALTER TABLE `properties` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `schema_version`
--

DROP TABLE IF EXISTS `schema_version`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `schema_version` (
  `version_rank` int(11) NOT NULL,
  `installed_rank` int(11) NOT NULL,
  `version` varchar(50) NOT NULL,
  `description` varchar(200) NOT NULL,
  `type` varchar(20) NOT NULL,
  `script` varchar(1000) NOT NULL,
  `checksum` int(11) DEFAULT NULL,
  `installed_by` varchar(100) NOT NULL,
  `installed_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `execution_time` int(11) NOT NULL,
  `success` tinyint(1) NOT NULL,
  PRIMARY KEY (`version`),
  KEY `schema_version_vr_idx` (`version_rank`),
  KEY `schema_version_ir_idx` (`installed_rank`),
  KEY `schema_version_s_idx` (`success`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `schema_version`
--

LOCK TABLES `schema_version` WRITE;
/*!40000 ALTER TABLE `schema_version` DISABLE KEYS */;
INSERT INTO `schema_version` VALUES (1,1,'1.00','Base version','INIT','Base version',NULL,'root','2016-05-13 05:23:05',0,1),(2,2,'2.00','ALTER logbooks status to state','SQL','V2.00__ALTER_logbooks_status_to_state.sql',-1775352058,'root','2016-05-13 05:23:05',15,1),(3,3,'2.01','ALTER logs status to state','SQL','V2.01__ALTER_logs_status_to_state.sql',104011789,'root','2016-05-13 05:23:05',11,1),(4,4,'2.02','ALTER properties status to state','SQL','V2.02__ALTER_properties_status_to_state.sql',-680189563,'root','2016-05-13 05:23:05',19,1),(5,5,'2.03','ALTER attributes status to state','SQL','V2.03__ALTER_attributes_status_to_state.sql',-207252449,'root','2016-05-13 05:23:05',12,1),(6,6,'2.04','ALTER logs logbooks drop columns','SQL','V2.04__ALTER_logs_logbooks_drop_columns.sql',-2067581210,'root','2016-05-13 05:23:05',5,1),(7,7,'2.05','CREATE entries','SQL','V2.05__CREATE_entries.sql',-16098960,'root','2016-05-13 05:23:05',3,1),(8,8,'2.06','ALTER logs md5recent','SQL','V2.06__ALTER_logs_md5recent.sql',-1367573323,'root','2016-05-13 05:23:05',4,1),(9,9,'2.07','DROP statuses','SQL','V2.07__DROP_statuses.sql',-1470090610,'root','2016-05-13 05:23:05',2,1),(10,10,'2.08','ALTER logs level to ENUM','SQL','V2.08__ALTER_logs_level_to_ENUM.sql',-308002669,'root','2016-05-13 05:23:05',11,1),(11,11,'2.09','DROP levels','SQL','V2.09__DROP_levels.sql',-352522219,'root','2016-05-13 05:23:05',2,1),(12,12,'2.10','ALTER logs','SQL','V2.10__ALTER_logs.sql',-16433912,'root','2016-05-13 05:23:05',14,1),(13,13,'2.11','ALTER fix all fkeys','SQL','V2.11__ALTER_fix_all_fkeys.sql',-340063373,'root','2016-05-13 05:23:05',51,1);
/*!40000 ALTER TABLE `schema_version` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `subscriptions`
--

DROP TABLE IF EXISTS `subscriptions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subscriptions` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `tag_id` int(11) unsigned NOT NULL,
  `email` varchar(250) NOT NULL DEFAULT '',
  `webhook` varchar(250) DEFAULT NULL,
  `level_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `subscriptions_tag_id_fk` (`tag_id`),
  CONSTRAINT `subscriptions_tag_id_fk` FOREIGN KEY (`tag_id`) REFERENCES `logbooks` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `subscriptions`
--

LOCK TABLES `subscriptions` WRITE;
/*!40000 ALTER TABLE `subscriptions` DISABLE KEYS */;
/*!40000 ALTER TABLE `subscriptions` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-05-16  9:36:30