aboutsummaryrefslogblamecommitdiffstats
path: root/spec/support/schemas/postgresql_schema.rb
blob: 23a48f5ad8ea4bfa5e679c38a0769b0b4e4c95f4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                   




                                   

                                     
    




                                                         
sql = <<-SQL
  DROP TABLE IF EXISTS users;
  CREATE TABLE users (
    id SERIAL PRIMARY KEY NOT NULL,
    name VARCHAR(255) NOT NULL
  );

  DROP TABLE IF EXISTS photos;
  CREATE TABLE photos (
    id SERIAL PRIMARY KEY NOT NULL,
    user_id INTEGER NOT NULL,
    camera_id INTEGER NOT NULL
  );
  DROP TABLE IF EXISTS developers;
  CREATE TABLE developers (
    id SERIAL PRIMARY KEY NOT NULL,
    name VARCHAR(255) NOT NULL,
    salary INTEGER NOT NULL,
    department VARCHAR(255) NOT NULL,
    created_at TIMESTAMP NOT NULL
  );
SQL

sql.split(/;/).select(&:present?).each do |sql_statement|
  ActiveRecord::Base.connection.execute sql_statement
end