Created
January 30, 2013 15:59
-
-
Save aalvesjr/4674247 to your computer and use it in GitHub Desktop.
Como pegar o script de criação do banco de dados de uma app Rails usando SQLite3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Caso você use windows precisara dos arquivos | |
-- * Precompiled Binaries for Windows | |
-- ** sqlite3.exe | |
-- ** sqlite3.dll | |
-- Ambos podem ser baixados em: http://www.sqlite.org/download.html | |
-- Feito isso, dentro da raiz do seu projeto executar o comando: | |
-- sqlite3 db/development.sqlite3 | |
-- isso deve abrir um promp de comandos do sqlite | |
-- depois: | |
-- .schema | |
-- ou se quiser mandar direto para um arquivo: | |
-- sqlite3 db/development.sqlite3 ".schema" > scripts.sql | |
-- Arquivo "scripts.sql" deve ter o conteudo mais ou menos assim: | |
CREATE TABLE "activities" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "timetable" varchar(255), "description" text, "meeting_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "address" varchar(255), "number" integer, "person_id" integer, "complement" varchar(255), "zipcode" varchar(255), "country_id" integer, "city" varchar(255), "neighborhood" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "courses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "name" varchar(255), "course_type" integer, "description" text, "active" boolean DEFAULT 't', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "instalments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "release_id" integer, "number" integer, "expiration_date" datetime, "paid_at" datetime, "amount" decimal, "amount_paid" decimal, "status_id" integer, "payment_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "interested_contacts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "date" varchar(255), "description" text, "interested_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "interesteds" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "email" varchar(255), "phone" varchar(255), "situation" integer, "interest" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "meetings" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "date" date, "team_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "people" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "cpf" varchar(255), "rg" varchar(255), "observations" text, "active" boolean, "type" varchar(255), "birth_date" varchar(255), "occupation" varchar(255), "sex" integer, "schooling" varchar(255), "relationship_elderly" integer, "notes" text, "rg_delivered" boolean DEFAULT 'f', "cpf_delivered" boolean DEFAULT 'f', "photo_delivered" boolean DEFAULT 'f', "cv_delivered" boolean DEFAULT 'f', "address_delivered" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "phones" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "type_number" integer, "number" varchar(255), "person_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "providers_services" ("provider_id" integer, "service_id" integer); | |
CREATE TABLE "registrations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "team_id" integer, "student_id" integer, "release_id" integer, "status" integer DEFAULT 0, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "releases" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "name" varchar(255), "category_id" integer, "total_amount" decimal, "number_instalments" integer, "first_paid" boolean, "fixed_payment" boolean, "description" text, "type" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "roles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)); | |
CREATE TABLE "roles_users" ("role_id" integer, "user_id" integer); | |
CREATE TABLE "schedules" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "service_id" integer, "provider_id" integer, "client_id" integer, "release_id" integer, "estimated_time" varchar(255), "number_days" integer, "date" datetime, "observations" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL); | |
CREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "number_days" integer, "estimated_time" varchar(255), "default_value" decimal, "inactive" boolean, "description" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "sessions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "session_id" varchar(255) NOT NULL, "data" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "teams" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar(255), "name" varchar(255), "course_id" integer, "season" integer, "limit" integer, "price" decimal, "class_length" integer, "workload" varchar(255), "note" text, "status" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(255), "password_hash" varchar(255), "password_salt" varchar(255), "name" varchar(255), "email" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
CREATE INDEX "index_activities_on_meeting_id" ON "activities" ("meeting_id"); | |
CREATE INDEX "index_activities_on_timetable" ON "activities" ("timetable"); | |
CREATE INDEX "index_activities_on_updated_at" ON "activities" ("updated_at"); | |
CREATE INDEX "index_addresses_on_address" ON "addresses" ("address"); | |
CREATE INDEX "index_addresses_on_country_id" ON "addresses" ("country_id"); | |
CREATE INDEX "index_addresses_on_person_id" ON "addresses" ("person_id"); | |
CREATE INDEX "index_addresses_on_updated_at" ON "addresses" ("updated_at"); | |
CREATE INDEX "index_courses_on_code" ON "courses" ("code"); | |
CREATE INDEX "index_courses_on_name" ON "courses" ("name"); | |
CREATE INDEX "index_courses_on_updated_at" ON "courses" ("updated_at"); | |
CREATE INDEX "index_instalments_on_expiration_date" ON "instalments" ("expiration_date"); | |
CREATE INDEX "index_instalments_on_release_id" ON "instalments" ("release_id"); | |
CREATE INDEX "index_instalments_on_updated_at" ON "instalments" ("updated_at"); | |
CREATE INDEX "index_interested_contacts_on_date" ON "interested_contacts" ("date"); | |
CREATE INDEX "index_interested_contacts_on_interested_id" ON "interested_contacts" ("interested_id"); | |
CREATE INDEX "index_interested_contacts_on_updated_at" ON "interested_contacts" ("updated_at"); | |
CREATE INDEX "index_interesteds_on_email" ON "interesteds" ("email"); | |
CREATE INDEX "index_interesteds_on_name" ON "interesteds" ("name"); | |
CREATE INDEX "index_interesteds_on_updated_at" ON "interesteds" ("updated_at"); | |
CREATE INDEX "index_meetings_on_date" ON "meetings" ("date"); | |
CREATE INDEX "index_meetings_on_team_id" ON "meetings" ("team_id"); | |
CREATE INDEX "index_meetings_on_updated_at" ON "meetings" ("updated_at"); | |
CREATE INDEX "index_people_on_birth_date" ON "people" ("birth_date"); | |
CREATE INDEX "index_people_on_cpf" ON "people" ("cpf"); | |
CREATE INDEX "index_people_on_name" ON "people" ("name"); | |
CREATE INDEX "index_people_on_rg" ON "people" ("rg"); | |
CREATE INDEX "index_people_on_type" ON "people" ("type"); | |
CREATE INDEX "index_people_on_updated_at" ON "people" ("updated_at"); | |
CREATE INDEX "index_phones_on_number" ON "phones" ("number"); | |
CREATE INDEX "index_phones_on_person_id" ON "phones" ("person_id"); | |
CREATE INDEX "index_phones_on_updated_at" ON "phones" ("updated_at"); | |
CREATE INDEX "index_registrations_on_code" ON "registrations" ("code"); | |
CREATE INDEX "index_registrations_on_release_id" ON "registrations" ("release_id"); | |
CREATE INDEX "index_registrations_on_student_id" ON "registrations" ("student_id"); | |
CREATE INDEX "index_registrations_on_team_id" ON "registrations" ("team_id"); | |
CREATE INDEX "index_registrations_on_updated_at" ON "registrations" ("updated_at"); | |
CREATE INDEX "index_releases_on_code" ON "releases" ("code"); | |
CREATE INDEX "index_releases_on_type" ON "releases" ("type"); | |
CREATE INDEX "index_releases_on_updated_at" ON "releases" ("updated_at"); | |
CREATE INDEX "index_roles_on_name" ON "roles" ("name"); | |
CREATE INDEX "index_schedules_on_client_id" ON "schedules" ("client_id"); | |
CREATE INDEX "index_schedules_on_code" ON "schedules" ("code"); | |
CREATE INDEX "index_schedules_on_date" ON "schedules" ("date"); | |
CREATE INDEX "index_schedules_on_provider_id" ON "schedules" ("provider_id"); | |
CREATE INDEX "index_schedules_on_release_id" ON "schedules" ("release_id"); | |
CREATE INDEX "index_schedules_on_service_id" ON "schedules" ("service_id"); | |
CREATE INDEX "index_schedules_on_updated_at" ON "schedules" ("updated_at"); | |
CREATE INDEX "index_services_on_name" ON "services" ("name"); | |
CREATE INDEX "index_services_on_updated_at" ON "services" ("updated_at"); | |
CREATE INDEX "index_sessions_on_session_id" ON "sessions" ("session_id"); | |
CREATE INDEX "index_sessions_on_updated_at" ON "sessions" ("updated_at"); | |
CREATE INDEX "index_teams_on_code" ON "teams" ("code"); | |
CREATE INDEX "index_teams_on_course_id" ON "teams" ("course_id"); | |
CREATE INDEX "index_teams_on_season" ON "teams" ("season"); | |
CREATE INDEX "index_teams_on_updated_at" ON "teams" ("updated_at"); | |
CREATE INDEX "index_users_on_email" ON "users" ("email"); | |
CREATE INDEX "index_users_on_login" ON "users" ("login"); | |
CREATE INDEX "index_users_on_updated_at" ON "users" ("updated_at"); | |
CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version"); | |
-- ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment