diff options
| author | mo khan <mo@mokhan.ca> | 2017-01-25 17:36:38 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2017-01-25 17:36:38 -0700 |
| commit | c9ef265c99611ac0a49bfd4541684e5af968ac5f (patch) | |
| tree | 934d2847b9ce71c68a975f9d96453aebbb22d925 /db | |
| parent | 1366c29d7698890a540847bc88b01d83aba30016 (diff) | |
create rake task to create database and schema.
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/0001_create_businesses.rb | 13 | ||||
| -rw-r--r-- | db/migrations/0002_create_computer.rb | 13 | ||||
| -rw-r--r-- | db/migrations/003_create_events.rb | 15 |
3 files changed, 41 insertions, 0 deletions
diff --git a/db/migrations/0001_create_businesses.rb b/db/migrations/0001_create_businesses.rb new file mode 100644 index 0000000..6bbd26b --- /dev/null +++ b/db/migrations/0001_create_businesses.rb @@ -0,0 +1,13 @@ +Sequel.migration do + up do + create_table :businesses do + primary_key :id + String :name, null: false + Integer :business_relationship_id, null: false + end + end + + down do + drop_table :businesses + end +end diff --git a/db/migrations/0002_create_computer.rb b/db/migrations/0002_create_computer.rb new file mode 100644 index 0000000..4a61ce8 --- /dev/null +++ b/db/migrations/0002_create_computer.rb @@ -0,0 +1,13 @@ +Sequel.migration do + up do + create_table :computers do + primary_key :id + TrueClass :active, null: false, default: true + foreign_key :business_id, :businesses + end + end + + down do + drop_table :computers + end +end diff --git a/db/migrations/003_create_events.rb b/db/migrations/003_create_events.rb new file mode 100644 index 0000000..f9273a2 --- /dev/null +++ b/db/migrations/003_create_events.rb @@ -0,0 +1,15 @@ +Sequel.migration do + up do + create_table :events do + primary_key :id + foreign_key :computer_id, :computers + String :type, null: false + String :data, text: true + DateTime :occurred_at, null: false + end + end + + down do + drop_table :events + end +end |
