aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/schemas/postgresql_schema.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/schemas/postgresql_schema.rb')
-rw-r--r--spec/support/schemas/postgresql_schema.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/support/schemas/postgresql_schema.rb b/spec/support/schemas/postgresql_schema.rb
new file mode 100644
index 0000000000..23a48f5ad8
--- /dev/null
+++ b/spec/support/schemas/postgresql_schema.rb
@@ -0,0 +1,26 @@
+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