-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
606 additions
and
117 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- | ||
-- Created by SQL::Translator::Producer::SQLite | ||
-- Created on Wed Jun 13 22:58:42 2012 | ||
-- | ||
|
||
BEGIN TRANSACTION; | ||
|
||
-- | ||
-- Table: post | ||
-- | ||
CREATE TABLE post ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
text text NOT NULL, | ||
tags varchar(331) NOT NULL DEFAULT '', | ||
-- ex. | AA BB CC | | ||
nickname varchar(32) NOT NULL, | ||
user_key varchar(64) NOT NULL, | ||
profile_image_url varchar(128) NOT NULL, | ||
plusplus int(10) NOT NULL DEFAULT 0, | ||
created_at_ms bigint(20) NOT NULL | ||
); | ||
|
||
-- | ||
-- Table: user | ||
-- | ||
CREATE TABLE user ( | ||
user_key varchar(64) NOT NULL, | ||
nickname varchar(32) NOT NULL, | ||
profile_image_url varchar(128) NOT NULL, | ||
sns_data_cache blob NOT NULL, | ||
created_at datetime NOT NULL, | ||
updated_at datetime NOT NULL, | ||
PRIMARY KEY (user_key) | ||
); | ||
|
||
-- | ||
-- Table: session | ||
-- | ||
CREATE TABLE session ( | ||
token varchar(64) NOT NULL, | ||
user_key varchar(64) NOT NULL, | ||
expire_at datetime NOT NULL, | ||
PRIMARY KEY (token) | ||
); | ||
|
||
COMMIT; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
use File::Basename qw/dirname/; | ||
use SQL::Translator; | ||
|
||
my $dirname = dirname __FILE__; | ||
|
||
my $translator = SQL::Translator->new; | ||
my $sql_for_sqlite = $translator->translate( | ||
from => 'MySQL', | ||
to => 'SQLite', | ||
filename => "$dirname/../db/init.sql", | ||
) or die $translator->error; | ||
|
||
# SQL::Translator doesn't output AUTOINCREMENT keyword, | ||
# but we need it to pass t/002_data_storage_mysql.t. | ||
$sql_for_sqlite =~ s/\b(INTEGER PRIMARY KEY)\b/$1 AUTOINCREMENT/g; | ||
|
||
open my $out, '>', "$dirname/../db/init_sqlite.sql" or die $!; | ||
print $out $sql_for_sqlite; | ||
|
||
__END__ | ||
=encoding utf8 | ||
=head1 NAME | ||
mysql_to_sqlite.pl - Translates from init.sql to init_sqlite.sql. | ||
=head1 DESCRIPTION | ||
This script is for authors. Please run this script when you change init.sql. | ||
=cut | ||
Oops, something went wrong.