mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Add liquibase + basic schema
This commit is contained in:
		
							parent
							
								
									4a84149b63
								
							
						
					
					
						commit
						c09ad0b8a9
					
				@ -1,4 +1,7 @@
 | 
			
		||||
unleash
 | 
			
		||||
=======
 | 
			
		||||
# unleash
 | 
			
		||||
 | 
			
		||||
feature toggle service
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
feature toggle server + clients
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,10 @@ unleash-server is a place to ask for the status of features.
 | 
			
		||||
# Important commands:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
// Set up DB
 | 
			
		||||
npm run db-create
 | 
			
		||||
npm run db-migrate
 | 
			
		||||
 | 
			
		||||
//Start server in dev-mode:
 | 
			
		||||
npm run start-dev
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,10 @@
 | 
			
		||||
        "start-dev": "NODE_ENV=local supervisor --ignore ./node_modules/ server.js",
 | 
			
		||||
        "test": "jshint server.js lib public/scripts test && mocha test test/*",
 | 
			
		||||
        "tdd": "mocha --watch test test/*",
 | 
			
		||||
        "test-bamboo-ci": "mocha test test/*"
 | 
			
		||||
        "test-bamboo-ci": "mocha test test/*",
 | 
			
		||||
        "db-create": "createdb unleash",
 | 
			
		||||
        "db-drop": "dropdb unleash",
 | 
			
		||||
        "db-migrate": "cd sql && grunt liquibase:update"
 | 
			
		||||
    },
 | 
			
		||||
    "dependencies": {
 | 
			
		||||
        "bluebird": "2.2.2",
 | 
			
		||||
@ -31,7 +34,9 @@
 | 
			
		||||
        "express-validator": "2.6.0",
 | 
			
		||||
        "ini": "1.3.0",
 | 
			
		||||
        "log4js": "0.6.21",
 | 
			
		||||
        "nconf": "0.6.9"
 | 
			
		||||
        "nconf": "0.6.9",
 | 
			
		||||
        "grunt": "^0.4.5",
 | 
			
		||||
        "grunt-liquibase": "^0.1.5"
 | 
			
		||||
    },
 | 
			
		||||
    "devDependencies": {
 | 
			
		||||
        "chai": "1.9.1",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										28
									
								
								unleash-server/sql/Gruntfile.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								unleash-server/sql/Gruntfile.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
var dbPort = (process.env.BOXEN_POSTGRESQL_PORT || '5432');
 | 
			
		||||
 | 
			
		||||
module.exports = function(grunt) {
 | 
			
		||||
    grunt.loadNpmTasks('grunt-liquibase');
 | 
			
		||||
 | 
			
		||||
    grunt.initConfig({
 | 
			
		||||
        liquibase : {
 | 
			
		||||
            options: {
 | 
			
		||||
                username : '',
 | 
			
		||||
                password : '',
 | 
			
		||||
                url : 'jdbc:postgresql://localhost:' + dbPort + '/unleash',
 | 
			
		||||
                changeLogFile: 'db_changes/db.changelog-master.xml'
 | 
			
		||||
            },
 | 
			
		||||
            update: {
 | 
			
		||||
                command: 'update'
 | 
			
		||||
            },
 | 
			
		||||
            dropAll: {
 | 
			
		||||
                command: 'dropAll'
 | 
			
		||||
            },
 | 
			
		||||
            version : {
 | 
			
		||||
                command: 'version'
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    grunt.registerTask('default', []);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										35
									
								
								unleash-server/sql/db_changes/001-create-tables.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								unleash-server/sql/db_changes/001-create-tables.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<databaseChangeLog
 | 
			
		||||
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
 | 
			
		||||
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
 | 
			
		||||
                        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
 | 
			
		||||
 | 
			
		||||
  <changeSet id="001-create-strategies" author="fijabakk">
 | 
			
		||||
    <sql>
 | 
			
		||||
      CREATE TABLE strategies (
 | 
			
		||||
        created_at timestamp default now(),
 | 
			
		||||
        name varchar(255) PRIMARY KEY NOT NULL,
 | 
			
		||||
        description text
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      CREATE TABLE features (
 | 
			
		||||
        created_at timestamp default now(),
 | 
			
		||||
        name varchar(255) PRIMARY KEY NOT NULL,
 | 
			
		||||
        strategy_name varchar(255) references strategies(name),
 | 
			
		||||
        parameters json
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      CREATE TABLE events (
 | 
			
		||||
        created_at timestamp default now(),
 | 
			
		||||
        type varchar(255) NOT NULL,
 | 
			
		||||
        data json
 | 
			
		||||
      );
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <rollback>
 | 
			
		||||
      DROP TABLE strategies;
 | 
			
		||||
      DROP TABLE features;
 | 
			
		||||
    </rollback>
 | 
			
		||||
  </changeSet>
 | 
			
		||||
</databaseChangeLog>
 | 
			
		||||
							
								
								
									
										11
									
								
								unleash-server/sql/db_changes/db.changelog-master.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								unleash-server/sql/db_changes/db.changelog-master.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
 | 
			
		||||
<databaseChangeLog
 | 
			
		||||
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
 | 
			
		||||
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
 | 
			
		||||
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
 | 
			
		||||
 | 
			
		||||
    <include relativeToChangelogFile="true" file="001-create-tables.xml"/>
 | 
			
		||||
 | 
			
		||||
</databaseChangeLog>
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user