blob: 8b7dac1c41bd15ad81c593e73f6515171d3b6f13 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
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
);
SQL
sql.split(/;/).select(&:present?).each do |sql_statement|
ActiveRecord::Base.connection.execute sql_statement
end
|