Skip to content
Snippets Groups Projects
Commit 9e4f191c authored by Tyler Lemburg's avatar Tyler Lemburg
Browse files

add more migrations

parent 7c47b026
No related branches found
No related tags found
No related merge requests found
Showing
with 426 additions and 0 deletions
require 'active_record'
class CreateDatabase < ActiveRecord::Migration
def change
create_table :resources do |t|
t.string :name
t.string :resource_type
t.string :model
t.text :description
t.integer :service_space_id
t.integer :minutes_per_reservation
t.boolean :needs_authorization
t.boolean :needs_approval
end
create_table :users do |t|
t.string :username
t.string :password_hash
t.string :email
t.string :first_name
t.string :last_name
t.string :university_status
t.datetime :date_created
t.integer :created_by_user_id
end
create_table :events do |t|
t.string :title
t.text :description
t.datetime :start_time
t.datetime :end_time
t.integer :service_space_id
end
create_table :reservations do |t|
t.integer :resource_id
t.integer :event_id
t.integer :user_id
t.datetime :start_time
t.datetime :end_time
t.boolean :is_training
end
create_table :resource_authorizations do |t|
t.integer :resource_id
t.integer :user_id
end
create_table :resource_approvers do |t|
t.integer :resource_id
t.integer :user_id
end
create_table :service_spaces do |t|
t.string :name
end
create_table :event_signups do |t|
t.integer :event_id
t.integer :user_id
t.string :name
end
end
end
\ No newline at end of file
require 'active_record'
class AddAdmin < ActiveRecord::Migration
def up
add_column :users, :is_admin, :boolean, :default => false
end
def down
remove_column :users, :is_admin
end
end
\ No newline at end of file
require 'active_record'
class AddEventTypes < ActiveRecord::Migration
def change
add_column :events, :event_type_id, :integer
create_table :event_types do |t|
t.string :description
t.integer :service_space_id
end
end
end
\ No newline at end of file
require 'active_record'
require 'models/service_space'
require 'models/event_type'
class InnovationStudioSs < ActiveRecord::Migration
def up
ss = ServiceSpace.create(
:name => 'Innovation Studio'
)
EventType.create(
:description => 'New Member Orientation',
:service_space_id => ss.id
)
EventType.create(
:description => 'Machine Training',
:service_space_id => ss.id
)
EventType.create(
:description => 'Advanced Skill-Based Workshop',
:service_space_id => ss.id
)
EventType.create(
:description => 'Creation Workshop',
:service_space_id => ss.id
)
EventType.create(
:description => 'General Workshop',
:service_space_id => ss.id
)
end
def down
ss = ServiceSpace.where(:name => 'Innovation Studio').first
EventType.where(:service_space_id => ss.id).delete_all
ss.delete
end
end
\ No newline at end of file
require 'active_record'
require 'models/location'
require 'models/service_space'
class AddLocations < ActiveRecord::Migration
def up
create_table :locations do |t|
t.string :name
t.string :streetaddress
t.string :streetaddress2
t.string :city
t.string :state
t.string :zip
t.string :additionalinfo
t.integer :service_space_id
end
Location.reset_column_information
ss = ServiceSpace.where(:name => "Innovation Studio").first
Location.create(
:name => 'Nebraska Innovation Studio',
:streetaddress => "2021 Transformation Drive",
:streetaddress2 => 'Suite 1500',
:city => 'Lincoln',
:state => 'NE',
:zip => '68508',
:additionalinfo => nil,
:service_space_id => ss.id
)
add_column :events, :location_id, :integer
end
def down
remove_column :events, :location_id
drop_table :locations
end
end
\ No newline at end of file
require 'active_record'
require 'models/service_space'
require 'models/resource'
class AddToolsFromDocument < ActiveRecord::Migration
def up
ss = ServiceSpace.where(:name => "Innovation Studio").first
[
['Oscilloscope', 'Rigo DS1054'],
['DC Power Supply', 'Gwinstek GPD-3303S'],
['Soldering Iron', 'Hakko FX-88D'],
['SMD Rework Station', 'Spark Fun 303D'],
['Vacuum Pen', 'Virtual Industries Inc. SMD-VAC HP'],
['Lead Free Solder Pot', 'SMT max ML-52T5'],
['Function/Arbitrary Waveform Generator', 'Rigol DG1022'],
['96" x 48" CNC Router', 'ShopBot PRSalpha'],
['Drill Press', 'Clausing 20'],
['Sliding Compound Miter Saw', 'Festrool Kapex KS 120 EB'],
['Table Saw', 'Saw Stop 10" Industrial Grade Cabinet Saw'],
['Laser Cutter', 'Epilog Fusion 32'],
['Large Format Printer', 'Epson Style Pro 4900'],
['3D Filament Desktop Printer', 'Ultimaker 2'],
['6" Industrial Belt Sander', 'Jet Stock # 414600'],
['12" Industrial Disc Sander', 'Jet Stock # 414602'],
['18" Variable Speed Scroll Saw', 'Delta'],
['18" Wood Band Saw', 'Laguna'],
['Panel Saw', 'Safety Speed'],
['3D Filament Desktop Printer', 'Stratasys Mojo'],
['Air Assist Pump (laser cutter)', 'GAST'],
['Desktop 3D Scanner', 'Next Engine'],
['Vinyl Cutter', 'Graphtec Cutting Plotter CE6000-60'],
['Industrial Sewing Machine', 'JUKI # 2DODE00141'],
['Standard Sewing Machine', 'Bernina 830'],
['Standard Sewing Machine', 'Bernina 803'],
['Ironing Station', '']
].each do |arr|
Resource.create(
:name => arr[0],
:resource_type => arr[0],
:model => arr[1],
:service_space_id => ss.id,
:needs_authorization => true,
:needs_approval => false
)
end
end
def down
ss = ServiceSpace.where(:name => "Innovation Studio").first
Resource.where(:service_space_id => ss.id).delete_all
end
end
\ No newline at end of file
require 'active_record'
class AddEmailEventSignup < ActiveRecord::Migration
def change
add_column :event_signups, :email, :string
end
end
\ No newline at end of file
require 'active_record'
class AddHours < ActiveRecord::Migration
def change
create_table :space_hours do |t|
t.integer :service_space_id
t.integer :day_of_week # 0 = Sunday, 6 = Saturday
t.datetime :effective_date # date to begin using these hours
t.boolean :one_off # is this all of this day moving forward or a special day
t.string :hours # encoded string describing the hours
end
end
end
\ No newline at end of file
require 'active_record'
require 'models/resource'
class ToolProperties < ActiveRecord::Migration
def up
add_column :resources, :is_reservable, :boolean
add_column :resources, :max_reservations_per_slot, :integer
Resource.reset_column_information
Resource.all.each do |resource|
resource.minutes_per_reservation = 60
resource.max_reservations_per_slot = 5
if resource.name == '96" x 48" CNC Router'
resource.minutes_per_reservation = 120
resource.max_reservations_per_slot = 3
end
resource.is_reservable = true
if resource.name == '3D Filament Desktop Printer'
resource.is_reservable = false
end
resource.save
end
end
def down
drop_column :resources, :is_reservable
drop_column :resources, :max_reservations_per_slot
end
end
\ No newline at end of file
require 'active_record'
require 'models/service_space'
require 'models/event_type'
class AddMoreEventTypes < ActiveRecord::Migration
def up
ss = ServiceSpace.find_by(
:name => 'Innovation Studio'
)
EventType.create(
:description => 'Free Event',
:service_space_id => ss.id
)
EventType.create(
:description => 'RSVP Only Event',
:service_space_id => ss.id
)
end
def down
ss = ServiceSpace.find_by(
:name => 'Innovation Studio'
)
EventType.where(:service_space_id => ss.id, :description => 'Free Event').delete
EventType.where(:service_space_id => ss.id, :description => 'RSVP Only Event').delete
end
end
\ No newline at end of file
require 'active_record'
class MaxSignups < ActiveRecord::Migration
def change
add_column :events, :max_signups, :integer
end
end
\ No newline at end of file
require 'active_record'
class AddResetPasswordColumns < ActiveRecord::Migration
def change
add_column :users, :reset_password_token, :string
add_column :users, :reset_password_expiry, :datetime
end
end
\ No newline at end of file
require 'active_record'
require 'models/user'
class AddSpaceStatus < ActiveRecord::Migration
def up
add_column :users, :space_status, :string
User.reset_column_information
User.all.each do |user|
user.space_status = 'current'
user.save
end
end
def down
drop_column :users, :space_status, :string
end
end
\ No newline at end of file
require 'active_record'
class AddResourceAuthorizationAuthorizedDate < ActiveRecord::Migration
def change
add_column :resource_authorizations, :authorized_date, :datetime
end
end
\ No newline at end of file
require 'active_record'
require 'models/user'
class AddServiceSpaceToUsers < ActiveRecord::Migration
def up
add_column :users, :service_space_id, :integer
User.reset_column_information
User.all.each do |user|
user.service_space_id = 1
user.save
end
end
def down
drop_column :users, :service_space_id
end
end
\ No newline at end of file
require 'active_record'
require 'models/user'
require 'models/permission'
class AddPermissions < ActiveRecord::Migration
def up
create_table :permissions do |t|
t.string :name
end
create_table :user_has_permissions do |t|
t.integer :user_id
t.integer :permission_id
end
Permission.reset_column_information
User.reset_column_information
# add the permissions to the DB
Permission.create(:name => 'Super User')
Permission.create(:name => 'Manage Users')
Permission.create(:name => 'Manage Resources')
Permission.create(:name => 'Manage Emails')
Permission.create(:name => 'Manage Space Hours')
Permission.create(:name => 'Manage Events')
Permission.create(:name => 'See Agenda')
# give all permissions including super user to tyler & lowad
permissions = Permission.all
tyler = User.find_by(:username => 'tyler')
lowad2 = User.find_by(:username => 'lowad2')
permissions.each do |perm|
tyler.permissions << perm
lowad2.permissions << perm
end
end
def down
drop_table :permissions
drop_table :user_has_permissions
end
end
\ No newline at end of file
require 'active_record'
require 'models/location'
class AddUnlEventsDetails < ActiveRecord::Migration
def change
add_column :events, :unl_events_id, :integer
add_column :locations, :unl_events_id, :integer
Location.reset_column_information
nis = Location.find_by(name: 'Nebraska Innovation Studio')
nis.unl_events_id = 11632
nis.save
end
end
\ No newline at end of file
require 'active_record'
class AddEventImagedata < ActiveRecord::Migration
def change
add_column :events, :imagedata, :longblob, :default => nil
add_column :events, :imagemime, :string, :default => nil
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment