Permalink
Browse files

* Some database boot strapping.

  • Loading branch information...
0 parents commit 786e600f1655f317be689effea76657267ff2b75 Erik Hollensbe committed Aug 5, 2010
Showing with 78 additions and 0 deletions.
  1. +12 −0 Rakefile
  2. +4 −0 database.yml
  3. +12 −0 lib/connector.rb
  4. +50 −0 schema.sql
@@ -0,0 +1,12 @@
+$:.unshift 'lib'
+require 'connector'
+
+task :load do
+ dbh = Connector.connect
+
+ statements = File.read('schema.sql').split(/\n---\n/)
+
+ statements.each do |stmt|
+ dbh.execute(stmt)
+ end
+end
@@ -0,0 +1,4 @@
+---
+database: project_list
+username: erikh
+password: ~
@@ -0,0 +1,12 @@
+require 'rubygems'
+require 'rdbi'
+gem 'rdbi-driver-postgresql'
+require 'rdbi/driver/postgresql'
+require 'yaml'
+
+module Connector
+ def self.connect
+ params = YAML.load_file('database.yml')
+ RDBI.connect(:PostgreSQL, params)
+ end
+end
@@ -0,0 +1,50 @@
+-- FIXME damnit, is a serial bigint or integer under the hood?
+create table users (
+ id serial primary key,
+ username varchar(20),
+ password varchar,
+ UNIQUE(username)
+)
+---
+create table user_profiles (
+ user_id integer primary key,
+ realname varchar(80) not null
+)
+---
+create table user_techs (
+ id serial primary key,
+ user_id integer not null,
+ -- not sure it makes sense to FK to something that's going to be so variant.
+ tech varchar(25) not null,
+ UNIQUE(user_id, tech)
+)
+---
+create table meetings (
+ id serial primary key,
+ meeting_time date,
+ UNIQUE(meeting_time)
+)
+---
+create table projects (
+ id serial primary key,
+ user_id integer not null,
+ name varchar(80),
+ description text,
+ UNIQUE(name)
+)
+---
+-- "this user is interested in this project"
+create table user_projects_interested (
+ id serial primary key,
+ user_id integer not null,
+ project_id integer not null,
+ meeting_id integer not null,
+ UNIQUE(user_id, project_id, meeting_id)
+)
+---
+create table project_meeting_assignment (
+ id serial primary key,
+ project_id integer not null,
+ meeting_id integer not null,
+ UNIQUE(project_id, meeting_id)
+)

0 comments on commit 786e600

Please sign in to comment.