[Bast-commits] r8072 - in ironman: .
plagger/lib/IronMan/Schema/Result
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Sat Dec 12 16:05:48 GMT 2009
Author: castaway
Date: 2009-12-12 16:05:48 +0000 (Sat, 12 Dec 2009)
New Revision: 8072
Added:
ironman/IronMan-Schema-0.01-0.02-MySQL.sql
ironman/IronMan-Schema-0.01-0.02-PostgreSQL.sql
ironman/IronMan-Schema-0.01-0.02-SQLite.sql
ironman/IronMan-Schema-0.02-MySQL.sql
ironman/IronMan-Schema-0.02-PostgreSQL.sql
ironman/IronMan-Schema-0.02-SQLite.sql
ironman/plagger/lib/IronMan/Schema/Result/Post.pm
Log:
Added posts table to schema
Added: ironman/IronMan-Schema-0.01-0.02-MySQL.sql
===================================================================
--- ironman/IronMan-Schema-0.01-0.02-MySQL.sql (rev 0)
+++ ironman/IronMan-Schema-0.01-0.02-MySQL.sql 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,34 @@
+-- Convert schema './IronMan-Schema-0.01-MySQL.sql' to 'IronMan::Schema v0.02':;
+
+BEGIN;
+
+SET foreign_key_checks=0;
+
+CREATE TABLE `posts` (
+ post_id integer NOT NULL auto_increment,
+ feed_id varchar(255) NOT NULL,
+ url text NOT NULL,
+ title text NOT NULL,
+ posted_on datetime NOT NULL,
+ summary text,
+ body text NOT NULL,
+ summary_filtered text,
+ body_filtered text,
+ INDEX posts_idx_feed_id (feed_id),
+ PRIMARY KEY (post_id),
+ UNIQUE url (url),
+ CONSTRAINT posts_fk_feed_id FOREIGN KEY (feed_id) REFERENCES `feed` (id)
+) ENGINE=InnoDB;
+
+SET foreign_key_checks=1;
+
+ALTER TABLE feed CHANGE COLUMN url url text,
+ CHANGE COLUMN link link text,
+ CHANGE COLUMN title title text;
+
+ALTER TABLE tag CHANGE COLUMN name name text NOT NULL;
+
+
+COMMIT;
+
+
Added: ironman/IronMan-Schema-0.01-0.02-PostgreSQL.sql
===================================================================
--- ironman/IronMan-Schema-0.01-0.02-PostgreSQL.sql (rev 0)
+++ ironman/IronMan-Schema-0.01-0.02-PostgreSQL.sql 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,26 @@
+-- Convert schema './IronMan-Schema-0.01-PostgreSQL.sql' to './IronMan-Schema-0.02-PostgreSQL.sql':;
+
+BEGIN;
+
+CREATE TABLE "posts" (
+ "post_id" serial NOT NULL,
+ "feed_id" character varying(255) NOT NULL,
+ "url" character varying(1024) NOT NULL,
+ "title" character varying(1024) NOT NULL,
+ "posted_on" timestamp NOT NULL,
+ "summary" character varying(2048),
+ "body" text NOT NULL,
+ "summary_filtered" character varying(2048),
+ "body_filtered" text,
+ PRIMARY KEY ("post_id"),
+ CONSTRAINT "url3" UNIQUE ("url")
+);
+CREATE INDEX "posts_idx_feed_id" on "posts" ("feed_id");
+
+ALTER TABLE "posts" ADD FOREIGN KEY ("feed_id")
+ REFERENCES "feed" ("id") DEFERRABLE;
+
+
+COMMIT;
+
+
Added: ironman/IronMan-Schema-0.01-0.02-SQLite.sql
===================================================================
--- ironman/IronMan-Schema-0.01-0.02-SQLite.sql (rev 0)
+++ ironman/IronMan-Schema-0.01-0.02-SQLite.sql 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,24 @@
+-- Convert schema './IronMan-Schema-0.01-SQLite.sql' to './IronMan-Schema-0.02-SQLite.sql':;
+
+BEGIN;
+
+CREATE TABLE posts (
+ post_id INTEGER PRIMARY KEY NOT NULL,
+ feed_id varchar(255) NOT NULL,
+ url varchar(1024) NOT NULL,
+ title varchar(1024) NOT NULL,
+ posted_on datetime NOT NULL,
+ summary varchar(2048),
+ body text NOT NULL,
+ summary_filtered varchar(2048),
+ body_filtered text
+);
+
+CREATE INDEX posts_idx_feed_id ON posts (feed_id);
+
+CREATE UNIQUE INDEX url02 ON posts (url);
+
+
+COMMIT;
+
+
Added: ironman/IronMan-Schema-0.02-MySQL.sql
===================================================================
--- ironman/IronMan-Schema-0.02-MySQL.sql (rev 0)
+++ ironman/IronMan-Schema-0.02-MySQL.sql 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,71 @@
+--
+-- Created by SQL::Translator::Producer::MySQL
+-- Created on Sat Dec 12 16:03:31 2009
+--
+SET foreign_key_checks=0;
+
+DROP TABLE IF EXISTS `feed`;
+
+--
+-- Table: `feed`
+--
+CREATE TABLE `feed` (
+ `id` varchar(255) NOT NULL,
+ `url` text,
+ `link` text,
+ `title` text,
+ `owner` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE `url` (`url`)
+) ENGINE=InnoDB;
+
+DROP TABLE IF EXISTS `tag`;
+
+--
+-- Table: `tag`
+--
+CREATE TABLE `tag` (
+ `id` integer NOT NULL auto_increment,
+ `name` text NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB;
+
+DROP TABLE IF EXISTS `posts`;
+
+--
+-- Table: `posts`
+--
+CREATE TABLE `posts` (
+ `post_id` integer NOT NULL auto_increment,
+ `feed_id` varchar(255) NOT NULL,
+ `url` text NOT NULL,
+ `title` text NOT NULL,
+ `posted_on` datetime NOT NULL,
+ `summary` text,
+ `body` text NOT NULL,
+ `summary_filtered` text,
+ `body_filtered` text,
+ INDEX posts_idx_feed_id (`feed_id`),
+ PRIMARY KEY (`post_id`),
+ UNIQUE `url` (`url`),
+ CONSTRAINT `posts_fk_feed_id` FOREIGN KEY (`feed_id`) REFERENCES `feed` (`id`)
+) ENGINE=InnoDB;
+
+DROP TABLE IF EXISTS `feed_tag_map`;
+
+--
+-- Table: `feed_tag_map`
+--
+CREATE TABLE `feed_tag_map` (
+ `feed` integer NOT NULL,
+ `tag` integer NOT NULL,
+ INDEX feed_tag_map_idx_feed (`feed`),
+ INDEX feed_tag_map_idx_tag (`tag`),
+ PRIMARY KEY (`feed`, `tag`),
+ CONSTRAINT `feed_tag_map_fk_feed` FOREIGN KEY (`feed`) REFERENCES `feed` (`id`),
+ CONSTRAINT `feed_tag_map_fk_tag` FOREIGN KEY (`tag`) REFERENCES `tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+SET foreign_key_checks=1;
+
+
Added: ironman/IronMan-Schema-0.02-PostgreSQL.sql
===================================================================
--- ironman/IronMan-Schema-0.02-PostgreSQL.sql (rev 0)
+++ ironman/IronMan-Schema-0.02-PostgreSQL.sql 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,73 @@
+--
+-- Created by SQL::Translator::Producer::PostgreSQL
+-- Created on Sat Dec 12 16:03:40 2009
+--
+--
+-- Table: feed
+--
+DROP TABLE "feed" CASCADE;
+CREATE TABLE "feed" (
+ "id" character varying(255) NOT NULL,
+ "url" character varying(1024),
+ "link" character varying(1024),
+ "title" character varying(1024),
+ "owner" character varying(255) NOT NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "url" UNIQUE ("url")
+);
+
+--
+-- Table: posts
+--
+DROP TABLE "posts" CASCADE;
+CREATE TABLE "posts" (
+ "post_id" serial NOT NULL,
+ "feed_id" character varying(255) NOT NULL,
+ "url" character varying(1024) NOT NULL,
+ "title" character varying(1024) NOT NULL,
+ "posted_on" timestamp NOT NULL,
+ "summary" character varying(2048),
+ "body" text NOT NULL,
+ "summary_filtered" character varying(2048),
+ "body_filtered" text,
+ PRIMARY KEY ("post_id"),
+ CONSTRAINT "url3" UNIQUE ("url")
+);
+CREATE INDEX "posts_idx_feed_id" on "posts" ("feed_id");
+
+--
+-- Table: tag
+--
+DROP TABLE "tag" CASCADE;
+CREATE TABLE "tag" (
+ "id" serial NOT NULL,
+ "name" character varying(1024) NOT NULL,
+ PRIMARY KEY ("id")
+);
+
+--
+-- Table: feed_tag_map
+--
+DROP TABLE "feed_tag_map" CASCADE;
+CREATE TABLE "feed_tag_map" (
+ "feed" integer NOT NULL,
+ "tag" integer NOT NULL,
+ PRIMARY KEY ("feed", "tag")
+);
+CREATE INDEX "feed_tag_map_idx_feed" on "feed_tag_map" ("feed");
+CREATE INDEX "feed_tag_map_idx_tag" on "feed_tag_map" ("tag");
+
+--
+-- Foreign Key Definitions
+--
+
+ALTER TABLE "posts" ADD FOREIGN KEY ("feed_id")
+ REFERENCES "feed" ("id") DEFERRABLE;
+
+ALTER TABLE "feed_tag_map" ADD FOREIGN KEY ("feed")
+ REFERENCES "feed" ("id") DEFERRABLE;
+
+ALTER TABLE "feed_tag_map" ADD FOREIGN KEY ("tag")
+ REFERENCES "tag" ("id") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
+
+
Added: ironman/IronMan-Schema-0.02-SQLite.sql
===================================================================
--- ironman/IronMan-Schema-0.02-SQLite.sql (rev 0)
+++ ironman/IronMan-Schema-0.02-SQLite.sql 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,72 @@
+--
+-- Created by SQL::Translator::Producer::SQLite
+-- Created on Sat Dec 12 16:03:36 2009
+--
+
+
+BEGIN TRANSACTION;
+
+--
+-- Table: feed
+--
+DROP TABLE feed;
+
+CREATE TABLE feed (
+ id varchar(255) NOT NULL,
+ url varchar(1024),
+ link varchar(1024),
+ title varchar(1024),
+ owner varchar(255) NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE UNIQUE INDEX url ON feed (url);
+
+--
+-- Table: posts
+--
+DROP TABLE posts;
+
+CREATE TABLE posts (
+ post_id INTEGER PRIMARY KEY NOT NULL,
+ feed_id varchar(255) NOT NULL,
+ url varchar(1024) NOT NULL,
+ title varchar(1024) NOT NULL,
+ posted_on datetime NOT NULL,
+ summary varchar(2048),
+ body text NOT NULL,
+ summary_filtered varchar(2048),
+ body_filtered text
+);
+
+CREATE INDEX posts_idx_feed_id ON posts (feed_id);
+
+CREATE UNIQUE INDEX url02 ON posts (url);
+
+--
+-- Table: tag
+--
+DROP TABLE tag;
+
+CREATE TABLE tag (
+ id INTEGER PRIMARY KEY NOT NULL,
+ name varchar(1024) NOT NULL
+);
+
+--
+-- Table: feed_tag_map
+--
+DROP TABLE feed_tag_map;
+
+CREATE TABLE feed_tag_map (
+ feed integer NOT NULL,
+ tag integer NOT NULL,
+ PRIMARY KEY (feed, tag)
+);
+
+CREATE INDEX feed_tag_map_idx_feed ON feed_tag_map (feed);
+
+CREATE INDEX feed_tag_map_idx_tag ON feed_tag_map (tag);
+
+COMMIT;
+
Added: ironman/plagger/lib/IronMan/Schema/Result/Post.pm
===================================================================
--- ironman/plagger/lib/IronMan/Schema/Result/Post.pm (rev 0)
+++ ironman/plagger/lib/IronMan/Schema/Result/Post.pm 2009-12-12 16:05:48 UTC (rev 8072)
@@ -0,0 +1,57 @@
+package IronMan::Schema::Result::Post;
+
+use strict;
+use warnings;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+__PACKAGE__->table('posts');
+__PACKAGE__->add_columns(
+ post_id => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ # FK to Feed
+ feed_id => {
+ data_type => 'varchar',
+ size => 255,
+ },
+ url => {
+ data_type => 'varchar',
+ size => 1024,
+ },
+ title => {
+ data_type => 'varchar',
+ size => 1024,
+ },
+ posted_on => {
+ data_type => 'datetime',
+ },
+ ## arbitrary size!
+ ## HTMLTruncate plugin to plagger truns to 300 at the moment
+ summary => {
+ data_type => 'varchar',
+ size => 2048,
+ is_nullable => 1,
+ },
+ body => {
+ data_type => 'text',
+ },
+ summary_filtered => {
+ data_type => 'varchar',
+ size => 2048,
+ is_nullable => 1,
+ },
+ body_filtered => {
+ data_type => 'text',
+ is_nullable => 1,
+ }
+ );
+
+__PACKAGE__->set_primary_key('post_id');
+__PACKAGE__->add_unique_constraint('url' => ['url']);
+
+__PACKAGE__->belongs_to('feed', 'IronMan::Schema::Result::Feed', 'feed_id');
+
+1;
More information about the Bast-commits
mailing list